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?
Agreed. So I'll keep it short.
1) Yup. Not backed by a DB mind you. An Object Data Source.
2) I made an UltraDataSource through the wizard of the grid. When you do that it is able to derive it's data schema from a data source. When you place an UltraDataSource on your form yourself manually from the toolbox, how do you make a data schema? Do you then define the schema manually?
3) Got it. I understand. No need to clarify this any further...
The only thing I'm saying is that the 'quirky behaviour when dealing with the data source at design-time' goes away by using an UltraDataSource. This is my observation. So please fiddle around with my sample and let me know what you find out. It was build with Visual Studio 2010 Ultimate, C# framework 3.5 and Infragistic's 12.1
This thread is getting very cluttered and confused. :)
The grid designer has 3 basic options:
1) Bind to an existing data source. This is what you were doing before.
2) Create a new UltraDataSource component on the form and bind to it. This is really just a convenience for creating a data source that isn't necessarily backed by a DataBase. It's no different than option 1, really, because you could already have an UltraDataSource on the form and just bind to it.
3) Manually define the schema with NO DATA SOURCE at design-time. This is the option I recommend. Using this option, there is no UltraDataSource. Your grid stores the schema, which you define manually, but there the DataSource property of the grid is null. You have to make sure that the bands and columns you define match up to the names of the real data source you will be using at run-time. And you must use the SetDataBinding method, you cannot explicitly set DataSource and DataMember at run-time. This is more work, since you have to duplicate your data structure in the designer, but it doesn't have any quirky issues when dealing with the data source at design-time, since there is no data source at design-time.
Using this approach, you can set up your layout at design-time, so you don't have to worry about the coding of a RowLayout. But if you want to learn more about that, you can search the forum for RowLayoutColumnInfo. I'm sure I've posted some sample code to create simple layouts before.
You also do not need to use an UltraDataSource, so you don't have to worry about adding it to the project data sources. The only real data source is the same one you are using now.
Creating an additional UltraDataSource should not be necessary.
I'll check out your sample and let you know what I find.
#1, #3) There is a difference. If you bind to a Datasource during the wizard, it'll create an UltraDataSource for you. If you bind to a datasource yourself later in the grid designer it won't. But if you say "manually" is the way to go with the schema, then I'll look into that
"Creating a complex RowLayout like this at run-time is pretty tricky and requires a lot of understanding about how RowLayouts work. So if you still want to go that route, I can try to create some simple sample code for you, but it's a lot of work, and it seems like you have a better path to achieve what you want, now."
I know, that's why I was asking for an example. Haha. Why do you think I'd love to continue to work with the grid designer? Doing it in code seems quite te hassle.
"I don't really use project data sources, myself, so I don't know if it's possible to make the UltraDataSource into one. I suspect that only works for DataSets / DataTables, since the functionality is built-in to Visual Studio and it doesn't know anything about the UltraDataSource."
Through the wizard the UltraDataSource uses one if you don't want to set up the data schema manually. It works for object data sources aswell. As you will see in my sample project...
"If you would like to post a sample that would allow us to reproduce the issue where your layout is being lost, then that would be great. I will still very much like to look into this and see if there is anything we can do on our end to fix it."
I've attached a sample project. I've done the following:
Form1 contains a grid I made through the wizard. The wizard creates a UltraDataSource.Form2 is made as followed:- Dubbelclick Ultragrid control in toolbox- Immediatly click "finish" in wizard.- Go to UltraWinGrid Designer- Choose Data Schema- Click button "Bind to a DataSource to Establish Schema"- Choose DataSource, Other Data Sources, Project Data Sources (remember this?), MockUpRepository- DataMember = people- Press "Ok" (a normal BindingSource is made)- Type in Form_LoadMockUpRepository rep = new MockUpRepository();this.ultraGrid1.DataSource = rep.People;- Run the application and see data displayed as expected- Stop running- Open grid designer and see how the grid 'lost' it's data schema- DON'T PRESS ANYTHING BUT THE BUTTON "CANCEL"- Suddenly the grid appears to 'know' the data schema again- Verify this by opening grid designer againStrange huh? Now if you've made a Row layout this little trick wouldn't help. Row layouts are lost.
Please follow the steps for form2 from "Run the application and see data displayed as expected" to see what I mean. You don't need to add the grid and code, because I've already done that. It's just there to show you what I did.
#1 and #3 are basically the same, then. Instead of an UltraDataSource, you go into the designer and tell the grid that you want manually define the schema. This will allow you to create bands and columns that match your real data source and then bind to the grid later and still give you the same functionality in design-time where you can visually re-arrange the columns.
Creating a complex RowLayout like this at run-time is pretty tricky and requires a lot of understanding about how RowLayouts work. So if you still want to go that route, I can try to create some simple sample code for you, but it's a lot of work, and it seems like you have a better path to achieve what you want, now.
I don't really use project data sources, myself, so I don't know if it's possible to make the UltraDataSource into one. I suspect that only works for DataSets / DataTables, since the functionality is built-in to Visual Studio and it doesn't know anything about the UltraDataSource.
If you would like to post a sample that would allow us to reproduce the issue where your layout is being lost, then that would be great. I will still very much like to look into this and see if there is anything we can do on our end to fix it.
Hey,
1) The features I'm talking about is the ability to bind at design time. That is a very nice feature. Saves a lot of work. You suggested not to do that. Understand?
2) I understand what you mean. I just mean that I wouldn't know where to begin in the sea of properties. So a small example that would make the grid look like this for example: http://es.infragistics.com/assets/images/helptopic/en/wingrid_work_with_row_layouts_02.png in code would be nice.
3) If you don't bind the datasource in design time to an UltraDataSource it'll keep forgetting the data schema (unless you make the schema manually). Maybe because of a quirck of Visual Studio like you said. Who knows. All I know is that when I've set an UltraDataSource as datasource to the grid (which derived it's data schema from an Object Datasource) it will not forget your data schema in the designer anymore. I can still provide the test project if you want to investigate this further?
p.s.: Project Datasource/Object Datasource is just when you click Data in Visual Studio's menu and then choose add new Datasource. You know?