Hi,
I have a project where I use a number of UltraWinGrids version 6.2. On the majority of grids when I set the order of the columns in the designer they appear in code as expected (Header.VisiblePosition = x), however on grids used in a series of screens, despite the code appearing to be the same the columns appear in a different order than what is specified in the designer.
Ultimately I just need to know what is being changed in the grids that causes them to ignore the visible position property? The band is being added, the visible position property is set correctly in code. I don't see any code that would change the default grid setting, but I must be missing something. Any ideas?
It appears from the code that the visible position is being changed when the control is bound to the data in these lines of code:
this.bindingSource1.DataSource = objBO.VBOData.DataSet;
this.ultraGrid1.SetDataBinding(this.bindingSource1, null, true);
//band[0].columns["mycolumn"].Header.VisiblePosition = 7
One thing I did try after looking through the forums was:
{
//e.Dialog.ColumnChooserControl.ResetSyncLookWithSourceGrid();
}
This does set the colums to the correct order, but would take away a lot of the combo box functionality.
Thanks,
Trevor
(yes I have spent too much time on this issue just to move column positions)
Hi Trevor,
My guess is that your design-time grid has a different structure than the data source you are binding it to. If the band names are not the same, then when you bind the grid, it will blow away everything in the layout and create a new layout from the data source.
Also, you should not set the DataSource property of the grid, you should use the SetDataBinding method, instead.
Personally, I find it much easier to simply arrange the columns inside the InitializeLayout event of the grid. That way you don't have to worry about losing the layout.
I would like to be able to see my changes for the grid in design mode, so setting them in intialize layout does not seem like a great option to me (unless it shows initalilze layout changes in design mode???).
What do you mean by the band names must be the same - the same as what?
I keep losing my layout information? What is the simplest way to keep this information and still use the design mode of the grid which I prefer?
Thanks
Howard Reagor
McKee Foods
hreagor said:What do you mean by the band names must be the same - the same as what?
The same as the names of the bands in the data source you will be binding to. When you bind the grid at run-time, everything has to match up exactly. If you bind the grid to a data source with a different number of columns, or the column names don't match, or the band names don't match, then the grid has to assume that the data source is different and it will throw away the layout and create a new layout based on the new data source.
Thanks for the information. I guess I am still not clear as to why what I am trying to do causes an issue. I thought I would put in more steps to clear it up.
1. I have a form with several UltraGrids on it. Some seem to work fine and do not lose their settings.
2. All I am doing in the designer is hiding some columns, changing the width, and chaning the column labels (for the most part)
3. I am binding it to a datasource and a datatable of that datasource via the designer. We do use WCF for data retrieveal, but I don't think this should matter as it still looks like a datatable on the client side of things. However, we do have to rebuild the WCF services from time to time as things change a little.
4. I have one band - "band[0] - 'FREEZER_BATCHES' which defaults to the name of the table (freezer_batches in this case - the one I am having trouble with). I have not changed that band name. I have not changed any key names either. Should I be changing the band name here? If so, to what name?
5. In this case, the grid has all the columns that the datasource has, but as mentioned in #2, I choose to hide some of them and change the default width and column heading.
6. All the column names in the grid match the column names in the datasource/table (and ultimately the database too).
When you say bind at run time, I assume you mean the binding that is happening auotmatically based on the fact that I choose a datasource/datatable via the designer??
Given what you are saying and what I have laid out above, it seems my columns should not be changing, but they are.
What is the best way for me to keep my column information and still be able to use the designer? Is there a set of steps on this somewhere that i can follow?
Howard
Hi Howard,
If your grid is bound at design-time and you are not explicitly re-binding it at run-time and it's just staying bound to the same data source, then you are absolutely right - the grid should not be changing the layout.
So either the data source you are using is doing something odd, like sending a reset notification for no reason, or else this is a bug in the grid. Are you using the latest version and hot fix of the controls? If not, I recommend downloading the latest hot fix and trying it out. If that does not help, you should Submit an incident to Infragistics Developer Support and if possible include a small sample project demonstrating the behavior do they can check it out and get it fixed.