If you are ChicagoBoy and [link|http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet.datagridcontrol/browse_frm/thread/8777eb1801fc8510/216709814fc7d3f0?lnk=st&q=datagrid+proportionally&rnum=7#216709814fc7d3f0|this] is your post then...
a) This code doesn't compile becuase Tables is not a member of SqlDataAdapter. I think you meant MyDataset.Tables(0)
b) You map the 2nd column to ProductDesc when it's called ProductName in the SQL query.
If this wasn't you or if these were transcription errors then I apologize but it does look just like what you are talking about, so lets move on.
The problem lies in these two lines:
MyDataset = New DataSet("Products")
MyDataAdapter.Fill(MyDataset)
The first line names the Dataset "Products"
The 2nd line doesn't name the table within the Dataset so it gets assigned a default name "Table". Further down you set myGridStyle.MappingName = "Products". That doesn't match "Table" so your style gets ignored. You should either set the MappingName to "Table", or better yet, change your Fill call to:
MyDataAdapter.Fill(MyDataset, "Products")
You might consider naming (the string name) your Dataset something else to avoid confusion.
As to why this is so complex and different from ASP.Net's Datagrid? The WinForms datagrid supports drilling down into hierarchical data, so it has support for these mappings so that the appropriate styles and column settings can be retrieved as the user drills into the data. The ASP.Net DataGrid doesn't have this feature.
As to why the WinForms DataGrid doesn't support proportional column sizing? My guess is they didn't want to have to loop thru all the column values, measuring each's length with the current font. ASP.Net's DataGrid can get away with this because:
a) It's made to display data in pages of limited length.
b) The browser can size the columns based on the generated HTML
The .Net 2.0 DataGridView has options for autosizing columns based on content or by setting relative weights for each column. It also doesn't do the hierarchical thing so you have one less level of abstraction to worry about