Hello,
I need to have 2 bands for my ultraWinGrid layout. In UltraGrid designer I added band[1] as a child for band[0]. I put ViewStyle property to MultiBand. But on InitializeLayout event I have only one band in e.Layout.Bands collection. What should I add in order to get the second band? (and I need to create the second band at design time, not at run time).
Thank you
Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn1 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("Band 1");
Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand2 = new Infragistics.Win.UltraWinGrid.UltraGridBand("Band 1", 0);
this.ugRC.DataSource = this.ultraDataSource1;
ultraGridBand2.MinRows = 1;
this.ugRC.DisplayLayout.BandsSerializer.Add(ultraGridBand2);
this.ugRC.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.Yes;
this.ugRC.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.ugRC_InitializeLayout);
You cannot add bands to the grid. The grid bands come from the data source. The BandSerializer is intended for internal use by the grid only, you should never use this class in your code.
If you are using an UltraDataSource, then you should be adding the bands and setting up the column in the UltraDataSource and then just bind it to the grid.
Thank you for the answer. Could you refer me to some example how to do this? Thanks.
Well, I'm not entirely sure if there are samples that add bands to the UltraDataSource in code. But if there are, they would be in th sample folder under UltraDataSource.
You could set up your UltraDataSource at design-time using the designer if you want. That might be easier.
The code isn't very complicated, though. There's a Band property on the UltraDataSource that represents the root band. You can add columns via the Columns collection and child bands via the ChildBands collection.
Hi Deon,
The most common cause of a problem like this is the Band Keys. When you set up your bands and columns at design-time, you must make sure that the key of each band matches the key of the data source you are assigning at run-time. The key of a child band is the name of the Relationship in the DataSet, not the table.
What I would do is go into the InitializeLayout event of your grid and loop through the band and the write out the Key of each band in the collection. Then go into the grid designer and make sure your design-time structure is using the same keys.
Hi Mike,
I have an ultragrid with 3 bands defined, and all column headers etc for the bands are set up using the designer. I retrieve 3 datatables, add them to a dataset, add parent-child relations and bind them to the grid. All columns in the grid are unbound.
My problem is that only the first band retains the designer-generated column settings, the second and third do not - columns hidden in the designer are shown, and the column headers are the column names from the datatable.
I could write code to manually set up the 2nd and 3rd bands, but is there a way for the grid to retain and bind the columns that have already been set up in the designer?
Thanks
Deon
ok...I find it...so answer to myself...
forgot datamember Initialization...mygrid.datamember = "myparentTable"...
bla bla bla.. ;)
Hi !
I have a very simple dataset with 2 tables... and just a relation, Parent-child.
The datasource contains the 2 tables and if I look the relation i'm able to see it..
when I assign the dataset at datasource property,I manage the settings grid about InitializeLayout.
And here happens the error : The controls havent 2 bands !
And if i look inside Band Members i see (All = 1... ) and the table current is the child table .
At the end of this speech...seems like that a table isn't loaded into the bands... into ultragrid.
And this is the code..
It's crash 'cause the table parent isn't in datasource's grid but when i assign via code
mygrd.datasource = mydataset (in dataset i have really 2 tables with 1 relation)!
private void ultraGridRilievi_InitializeLayout(object sender, InitializeLayoutEventArgs e) { try { string s = ultraGridRilievi.DisplayLayout.Bands[0].Key; ultraGridRilievi.DisplayLayout.Bands[0].Columns["NomeGruppo"].Hidden = false; ultraGridRilievi.DisplayLayout.Bands[0].Columns["Misura"].Hidden = false; ultraGridRilievi.DisplayLayout.Bands[0].Columns["Documento"].Hidden = true; ultraGridRilievi.DisplayLayout.Bands[0].Columns["GruppoRilievo"].Hidden = true; ultraGridRilievi.DisplayLayout.Bands[1].Columns["Documento"].Hidden = true; ultraGridRilievi.DisplayLayout.Bands[1].Columns["Nome"].CellActivation = Activation.AllowEdit; ultraGridRilievi.DisplayLayout.Bands[1].Columns["ObjIDRilievo"].Hidden = true; ultraGridRilievi.DisplayLayout.Bands[1].Columns["GruppoRilievo"].Hidden = true; } catch (System.Exception er) { MessageBox.Show("Error in ultraGridRilievi_InitializeLayout " + er.Message); } }
any idea ?
of course the grid is multiband..
It's hard to say what's going on here as there's not much to go on. You should probably submit a sample to Developer Support.
-Matt