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?
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?
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.
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...
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?