Dear Infragistics,
I have a collection of objects as my datasource. I keep binding these objects in the designer to the grid through a binding source for the data schema. Else the band and column settings won't work so that I can start designing row layouts. But every time i close and open the designer it 'forgot' the Data Schema. When I click on it to set it, it 'knows' the correct bindingsource. So it did not completely forget. But I need to reapply it. Therefor it also doesn't remember the row layout I designed.
What am I doing wrong?
Hi,
1) I'm a little confused by your response here. I'm not suggesting that you do not use the WinGrid. I merely meant that you don't have to bind the grid at design-time. You could set up the schema in the grid manually without binding and then bind at run-time.
2) An example of what, exactly? I meant that you can write code to position the columns or arrange the layout however you want. I can't provide you an example, because I don't have any idea what kinds of things you are doing to your layout. BTW.... another option would be to set up your layout, then save the layout to a file or into the grid's Layouts collection, and then load that layout into the grid at design-time.
3) You certainly do not HAVE to use an UltraDataSource, although this is kinda what happens internally when you use option 1 as I suggested. You can use UltraDataSource if you want to, as a sort've intermediary, but it's not required. I'm really not ssure what you mean by a Project DataSource. I don't know if that's possible.
I have the solution.
0) Agreed on the BindingList. Been working so long with Observable collections in WPF that I forgot about bindinglists. But simply changing my lists to bindinglists didn't do the trick.
1) I'll check it out. Thanks. But your grid has such a nice feature, seems a waste not to use it.
2) I'm very interested in that. Do you have a simple example (or a link to an example) for me please?
3) I've been trying to do this for you when I accidentally found the problem. To make a long story short, apparantly you need to use the UltraDataSource instead of a regular DataSource. I followed the grid's wizard and it asked me if I wanted to create a UltraDataSource and I thought, oh well... Why not. And suddenly my mock up project worked. I went to my project, set an UltraDataSource and voila. It works. One small question thought, how do you manually set the UltraDataSource to extract the schema of a Project DataSource? I've been doing that now by removing my grid, adding it anew and follow the wizard.
So 2 small questions left, if you are willing to help me out.
1) See point 2, I would really love to follow an example for that situation so I'm not depending on the designer.
2) How to you set the UltraDataSource to a Project DataSource via it's properties? Couldn't find it really...
My best guess is that this is a quirk of Visual Studio where it's not able to get the data hierarchy - most likely because you are using a List<T> at design-time. List<T> isn't really a good data source to use for binding, anyway. I would strongly recommend that you change it to a BindingList<T>. BindingList<T> is specifically designed for data binding. Using List will have all sorts of limitations.
If that doesn't help with this issue, then I'd recommend one of the following:
1) Don't bind the grid at design-time. Instead, create the schema in the grid designer manually (without assigning a DataSource). Then bind at run-time. Check out this article for more details:
HOWTO:How can I define columns in the grid at Design-time and bind them at run-time so that some fields of the data are excluded from the grid?
2) Don't design the layout at design-time. Do it at run-time in the InitializeLayout event of the grid.
3) Post a small sample project demonstrating the issue so we can investigate and see if there's anything we can do. We would, of course, be happy to look into the issue, but frankly I'm not optimistic about finding a solution. Like I said, this is most likely a quirk of how Visual Studio is handling the data source rather than a problem in the grid designer. The designer works in other cases, so if it's not able to get the data in this case, it's almost certainly because it's simply not available for whatever reason.
Update:
- I open grid designer
- Bind to bindingsource, so it has a dataschema
- Choose band #1 (Orders) to alter row layout
- I make some adjustments to the layout of the row and save my changes.
- Run the program and see my alterations, but would like to change something
- I stop the program and go back to it's grid designer
- Grid designer looks like it has no bindingsource attached and therefor no dataschema (read: I see no bands)
- I do nothing else but cancel the grid designer (idea of a colleague of mine because he dealt with this before).
- I reopen the grid designer
- Suddenly the grid designer has it's bindingsource again, therefor it's dataschema and therefor the bands I expected to see.
- But unfortunatly when I open Band #1 (Orders) to make changes to the row layout it has forgotten my previous changes and I have to start all over again.
- My colleague asks me why I use 11.2 because we have 12.1. So I quickly upgrade to 12.1
- Same results alas.
Im sorry to say, but the behaviour seems buggy to us. Is this a known issue with previous versions?
Hi Mike,
I apologize (again).
"And when you say "designer", are you talking about the grid designer or the form's designer?"
1) I'm talking about the grid designer.
"Are you saying that the DataSource property of your grid is no longer bound to the same BindingSource when you re-open the designer?"
2) Sort of... That's is the weird part. I want to go back to "Band and column settings" but it's missing a + icon so I can't expand it to see my bands. It's complaining that it needs a Data Schema. Well, I'm setting the Data Schema in Basic Settings all the time, but apparantly it keeps 'forgetting' the data schema. The weird part is though that when I go to Data Schema it shows the correct bindingsource, saying the grid is bound to this source. It seems I just need to reapply that.and because I'm reapplying the bindingsource it forgets the row layouts that I made.
"Also, what version of the controls are you using?"
3) 11.2
"Also... how are you creating a collection of objects and populating it at design-time?"
4) I have a class Person, with a property List<Order> Orders. Let's say I want to make the Order rows look nice in row layout designer. I've added "Project Datasource". Then I choose Object, then I choose Person and Order. They show up in the solution explorer as Datasources. When I point from the Datasource property of the grid to datasource Person a BindingSource is created.
Is it more clear this way?