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,
I'm having a hard time following you.
What, exactly, is being lost?
Are you saying that the DataSource property of your grid is no longer bound to the same BindingSource when you re-open the designer?
And when you say "designer", are you talking about the grid designer or the form's designer?
Also, what version of the controls are you using?
Also... how are you creating a collection of objects and populating it at design-time?
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?
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.
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?
#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.
#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.
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.
Oh, yeah. I think we do one every month (or at least try to) for bug fixes and such.
Anyway, glad we got this all worked out.
Mike,
I've never realized you guys have service releases in between. I've downloaded and installed the latest and now everything works as expected.
All this trouble...
Well thanks alot for your time and help.
I followed your steps but you lose me on step 8. I am not seeing any such problem.
It could be that this was an issue that has already been fixed. Try getting the latest service release and see if that helps.
How to get the latest service release - Infragistics Community
If not, then there must be something different on your machine that is causing this. Do you have the latest service pack(s) for Visual Studio? I'm using SP1.
Mike Saltzman said:Am I missing a step?
... No *sigh*. Doesn't seem like it... I didn't change the column/row layout or rearrange columns because it doesn't matter.
Look, please follow these steps exactly:
1) I go to the grid's Designer Dialog on Form2.
2) I click on the Data Schema button
3) I click on the Bind to a DataSource to Establish Schema button
4) Datasource = mockUprepositoryBindingSource and DataMember = People, press OK.
5) Press OK again. Notice mockup layout in grid in the designer of Form2. Looks good.
6) Run project (Form2 starts up)
7) Grid looks fine. I stop running the project.
8) Designer of Form2 is shown and i immediatly notice the mockup layout in the grid is not there (as if not bound to a source).
9) I click on the control and the properties say that the DataSource is still mockUprepositoryBindingSource and the DataMember is still People, so that seems fine.
10) I run it again, everything is fine. I'm starting to wonder what my problem was in the 1st place...
11) Stop running again (again I see no mockup layout as it should on a bound Infragistic's grid).
12) So to make sure, I open the grid's Designer Dialog again.
13) Now in the grid's Designer Dialog it has NO Data Schema (Band and Column Settings are empty... I see no + sign infront of it).
14) I press Cancel button as a little trick I've heard by a colleague of mine and I immediatly see mockup layout in grid again... (huh?)
15) I open the grid's Designer Dialog and Bands And Column Settings are filled (+ sign is shown infront of it) which indicates it has a Data schema and is correctly bound to my bindingsource. Ok, awesome... Looking good... (despite having to press Cancel to see it)
16) I go to Band[2] Lines to Column arrangement Overview, choose Use Row Layout and click Design Column Arrangement Now to mess around with Row Layout.
17) Save changes in grid's designer and go check the Designer of Form2. Mockup layout in grid looks as expected after my changes. I run Form2, layout of grid looks as expected and Data in it too. Good!
18) Stop running program and see in designer of Form2 that mockup layout is gone again in grid (as I've observed a couple of times now). Properties tell me again it should be bound to my binding source. But you know what, my Row Layout needs an adjustment...
19) So I open the grid's Designer Dialog and it has NO Data Schema (Band and Column Settings are empty... I see no + sign infront of it). So I can't adjust the row Layout of Band[2] Lines, because it has no Bands in the designer right now.
20) But I remembered the trick and I press "Cancel" button
21) I see my mockup layout again (so it's bound to my bindingsource correctly) but when I inspect the layout of the bands I notice band[2] Lines has standard layout again. Huh? Where's my row Layout.
22) I open the grid's Designer Dialog and I go to Band[2] Lines to Column arrangement Overview and it's on Use Groups And Levels. It's not on Use Row Layout anymore. Just to make sure I click "Design Column Arrangement Now", but alas my former Row Layout is gone.
I have made the steps as clear as possible. If you follow these steps and any step is different from what you are observing please let me know. Then we have a difference in systems. But this is what i'm observing.
DannyvdK said: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.
Of course it does. That is not surprising at all. Because UltraDataSource is a data source specifically designed to be used both at design-time and run-time. I am certain you would not have any such problems using a DataSet or DataTable, either.
It's only because you are using your own custom objects at design-time that you are experiencing any unusual behavior.
Anyway.. this morning I tried out your sample and tried to reproduce the problem you are getting and I am not seeing any issues. When I open your sample, and look at Form2, there isn't any schema here to lose. That is... I see the three column in order and there has been no modification of the schema - the band is still using GroupAndLevels layout which is the default.
So, as a test, I went into the grid designer and changed this so that this band is using a ColumnLayout and I rearranged the columns. I ran the sample and everything looks fine at run-time - it looks just the way I set it up.
I stopped running the sample and then went back into the grid designer and everything is still there, the layout is still fine. I also tried closing and re-opening the form designer just to be sure, but everything seems to be working fine for me no matter what I do.
Am I missing a step?