Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
11454 | Mar 5,2004 07:53 PM UTC | Mar 8,2004 08:50 AM UTC | WinForms | 3 |
![]() |
Tags: Grouping |
private void InitializeDataTable()
{
int recordCount = 100;
Random random = new Random(DateTime.Now.Millisecond);
string[] states = new string[]{"North Carolina", "South Carolina", "Washington", "Nevada", "Ohio"};
int numStates = states.GetLength(0);
string nameFormat = "Name{0}";
this.table = new DataTable("Test");
DataColumn col = table.Columns.Add();
col.DataType = typeof(string);
col.ColumnName = "Name";
col = table.Columns.Add();
col.DataType = typeof(string);
col.ColumnName = "State";
col = table.Columns.Add();
col.DataType = typeof(int);
col.ColumnName = "Zip";
for(int i = 0; i < recordCount; i++)
{
DataRow row = this.table.NewRow();
row["Name"] = string.Format(nameFormat, i);
row["State"] = states[random.Next(numStates-1)];
row["Zip"] = random.Next(9999);
this.table.Rows.Add(row);
}
}
Stefan Hoenig
//in formload
this.gridGroupingControl1.TableControl.Model.QueryColWidth += new GridRowColSizeEventHandler(grid_QueryColWidth);
this.SCROLLBARWIDTH = SystemInformation.VerticalScrollBarWidth;
this.lastCol = myDataTable.Columns.Count + 1;
//the handler private void grid_QueryColWidth(object sender, GridRowColSizeEventArgs e) { if(e.Index == this.lastCol) { int vscrollwidth = ((this.gridGroupingControl1.TableControl.Model.RowHeights.GetTotal(0, this.gridGroupingControl1.TableControl.Model.RowCount) + this.gridGroupingControl1.TableOptions.CaptionRowHeight) > this.gridGroupingControl1.ClientSize.Height) ? SCROLLBARWIDTH :0; e.Size = this.gridGroupingControl1.ClientSize.Width - this.gridGroupingControl1.TableControl.Model.ColWidths.GetTotal(0, e.Index - 1) - vscrollwidth; e.Handled = true; } }
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.