Why is it that I have no problem binding to a grid that has been dropped onto a form but if you declare a grid in code and bind to it, it always comes back with 0 columns.
Easy sample program:
Infragistics.Win.UltraWinGrid.UltraGrid myGrid = new Infragistics.Win.UltraWinGrid.UltraGrid();
List<int> myList = new List<int>();
myList.Add( 1 );
myList.Add( 2 );
myGrid.DataSource = myList;
myGrid.displayLayout.Bands[0].Columns.Count == 0 whereas if I had dropped a grid to the form, and did the exact same thing, I would get a column come back.
basically I am trying to code a custom drop down(by extending from ultratext editor and declaring a grid inside but now I cannot bind data to the drop down grid)
A grid with no form has no BindingContext. Also, if you don't add it to the form's Controls collection, it won't get disposed.
So you probably just have to do this.Controls.Add(myGrid) before you set the grid's DataSource and that should fix it.
I did that and it is still not working... I may be going about this the wrong way.
I am creating a class extending from UltraTextEditor and declaring the grid inside of that. Using this.Controls.Add is technically not adding it to a Form, so I guess that's why i am still seeing 0 rows.
Please see my post here: http://community.infragistics.com/forums/p/32243/175757.aspx#175757
Basically as a solution to that post, I am creating my own extended class so that I can pass the value I require from the parent row in to a property of the custom drop down so it can be accessed when the custom drop down is initializing. If you can help me with that post, then I won't need to go down this path of making a class.
BCCollins said:I am creating a class extending from UltraTextEditor and declaring the grid inside of that. Using this.Controls.Add is technically not adding it to a Form, so I guess that's why i am still seeing 0 rows.
Okay. You are probably right.
In that case, the best thing to do would probably be to trap when the TextBox is added to a form and then update the BindingContext at that point. that might be a bit complex, though. You probably have to use the OnSiteChanged method.
Another option, which is slightly less efficient would be to simply create a new BindingContext.
grid.BindingContext = new BindingContext();