I have a grid that when the window form is first loaded has a lot of horizontal scroll space on the right side of the last column. I then click the save button that goes out to the DB to get data and sets up the grid the same way as when the form first loaded but with the new row. This time the grid doesn't have any extra horizontal scroll space to the right of the last column. Why would refreshing the grid with this new row make any difference. The data is grabbed the same way and the grid is set up the same way upon loading the form as it is when any row is added.
One thing I've found is that I'm setting the datasource of the grid to a collection that has a lot of items in it. I try hidding all of these items and then only showing two of the items. Doing this gives me all of this extra horizontal space. If I set the datasource of the grid to a datatable that contains only the two columns I want to show then I don't have the extra horizontal space.
I've found a solution to the problem but was wondering why I had a problem when setting the datasource of the grid to the collection. This doesn't seem like it should happen and I shouldn't need to create a new datatable to fix this problem. Thanks for any explanation.
Richdjw
You had said that you found a solution to the problem and I was wondering what that was. I am having the same issue and hidding the child bands isn't an option.
Thanks.
I created a new dataset and populated that dataset with only the fields I needed from my original collection. My collection had about 10 properties in it but I only wanted to see 3 properties in the grid. This seems like extra work I shouldn't have to do, but its the only solution I found. Hopefully this helps you.
I had a same problem and I followed Mike's suggestion. This seemed to have work:
MyGrd.DisplayLayout.ViewStyle =
ViewStyle.SingleBand;
This issue occurs only when when you are binding to a datasource that has another collection inside it.