Hello,
I'm populating an UltraWinGrid with a DataSource:
sourceDataTable = new DataTable("Client");OleDbDataAdapter adaptation = new OleDbDataAdapter("select * from Client", strConn);adaptation.Fill((System.Data.DataTable)sourceDataTable); this.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.memberGrid)).BeginInit(); this.memberGrid.DataSource = ((System.Data.DataTable)sourceDataTable);((System.ComponentModel.ISupportInitialize)(this.memberGrid)).EndInit();this.ResumeLayout(false);
sourceDataTable = new DataTable("Client");OleDbDataAdapter adaptation = new OleDbDataAdapter("select * from Client", strConn);adaptation.Fill((System.Data.DataTable)sourceDataTable);
this.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.memberGrid)).BeginInit(); this.memberGrid.DataSource = ((System.Data.DataTable)sourceDataTable);((System.ComponentModel.ISupportInitialize)(this.memberGrid)).EndInit();this.ResumeLayout(false);
And then immediately afterwards, I want to group by a particular column:
this.memberGrid.DisplayLayout.Bands[0].SortedColumns.Add("Surname", false, true);
This fails. My debugger shows that this.memberGrid.Rows.Band.Columns.Count evaluates to 0. However, after some "time", the UltraWinGrid is succesfully populated by the the datasource.
How can I force the UltraWinGrid to be populated by the DataSource? Is there something that I'm forgetting?
Thanks in advance,
Indika
Were you calling the ISupportInitialize and the SuspendLayout in your code? I assumed that the was the Windows Form Designer Generated code. You should not be using that in your own code, ISupportInitialize is for serialization, there is no reason to ever call that code explicitly.
Yes, the grid is in a form. I don't know why, but removing the (System.ComponentModel.ISupportInitialize) commands results in the grid being updated immediately. Strange.
There's really not much here to go on. This could be caused by any number of things. Is the grid on a form?
The best thing to do would probably be to add the sorted column in the InitializeLayout event.