G
Guest
I am using the following code to initialize the gridFilmedRoutes DataGridView.
private void InitializeGrid() {
gridFilmedRoutes.DataSource = new BindingList<FilmedRouteInfo>();
// Set up a checkbox column for the Available property
gridFilmedRoutes.Columns.Remove("Available");
DataGridViewColumn c = new DataGridViewCheckBoxColumn(true);
c.Name = c.DataPropertyName = "Available";
gridFilmedRoutes.Columns.Insert(0, c);
// Set the order of the remaining columns
//gridFilmedRoutes.Columns["ID"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["RemovableMediaLabel"].DisplayIndex =
1;
//gridFilmedRoutes.Columns["ImageVersion"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["EndARM"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["BegARM"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["RRQ"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["RRT"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["SRnum"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["GeoArea"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["Year"].DisplayIndex = 1;
gridFilmedRoutes.Columns["Year"].DisplayIndex = 1;
gridFilmedRoutes.Columns["GeoArea"].DisplayIndex = 2;
gridFilmedRoutes.Columns["SRnum"].DisplayIndex = 3;
gridFilmedRoutes.Columns["RRT"].DisplayIndex = 4;
gridFilmedRoutes.Columns["RRQ"].DisplayIndex = 5;
gridFilmedRoutes.Columns["BegARM"].DisplayIndex = 6;
gridFilmedRoutes.Columns["EndARM"].DisplayIndex = 7;
gridFilmedRoutes.Columns["ImageVersion"].DisplayIndex = 8;
gridFilmedRoutes.Columns["RemovableMediaLabel"].DisplayIndex = 9;
gridFilmedRoutes.Columns["ID"].DisplayIndex = 10;
MessageBox.Show(gridFilmedRoutes.Columns.Count.ToString());
}
I can pause execution at the MessageBox line and verify, in the VS 2005
debugger, that the DisplayIndex values for each statement appear to have been
set correctly.
InitializeGrid() is called only once, at the end of my Form's constructor.
There is no other code setting the DataSource property of gridFilmedRoutes.
There are times, however, when the list of items in the DataSource is
cleared via the following call.
((BindingList<FilmedRouteInfo>)gridFilmedRoutes.DataSource).Clear();
Originally, I was going to remove all columns using
"gridFilmedRoutes.Columns.Clear()" and then add them in the order I wanted
them, but the Clear method did nothing. I imagine I could remove them
individually, like I did with the "Available" column, but I figured I must be
missing something.
Any ideas would be appreciated. Thanx,
Don
private void InitializeGrid() {
gridFilmedRoutes.DataSource = new BindingList<FilmedRouteInfo>();
// Set up a checkbox column for the Available property
gridFilmedRoutes.Columns.Remove("Available");
DataGridViewColumn c = new DataGridViewCheckBoxColumn(true);
c.Name = c.DataPropertyName = "Available";
gridFilmedRoutes.Columns.Insert(0, c);
// Set the order of the remaining columns
//gridFilmedRoutes.Columns["ID"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["RemovableMediaLabel"].DisplayIndex =
1;
//gridFilmedRoutes.Columns["ImageVersion"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["EndARM"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["BegARM"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["RRQ"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["RRT"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["SRnum"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["GeoArea"].DisplayIndex = 1;
//gridFilmedRoutes.Columns["Year"].DisplayIndex = 1;
gridFilmedRoutes.Columns["Year"].DisplayIndex = 1;
gridFilmedRoutes.Columns["GeoArea"].DisplayIndex = 2;
gridFilmedRoutes.Columns["SRnum"].DisplayIndex = 3;
gridFilmedRoutes.Columns["RRT"].DisplayIndex = 4;
gridFilmedRoutes.Columns["RRQ"].DisplayIndex = 5;
gridFilmedRoutes.Columns["BegARM"].DisplayIndex = 6;
gridFilmedRoutes.Columns["EndARM"].DisplayIndex = 7;
gridFilmedRoutes.Columns["ImageVersion"].DisplayIndex = 8;
gridFilmedRoutes.Columns["RemovableMediaLabel"].DisplayIndex = 9;
gridFilmedRoutes.Columns["ID"].DisplayIndex = 10;
MessageBox.Show(gridFilmedRoutes.Columns.Count.ToString());
}
I can pause execution at the MessageBox line and verify, in the VS 2005
debugger, that the DisplayIndex values for each statement appear to have been
set correctly.
InitializeGrid() is called only once, at the end of my Form's constructor.
There is no other code setting the DataSource property of gridFilmedRoutes.
There are times, however, when the list of items in the DataSource is
cleared via the following call.
((BindingList<FilmedRouteInfo>)gridFilmedRoutes.DataSource).Clear();
Originally, I was going to remove all columns using
"gridFilmedRoutes.Columns.Clear()" and then add them in the order I wanted
them, but the Clear method did nothing. I imagine I could remove them
individually, like I did with the "Available" column, but I figured I must be
missing something.
Any ideas would be appreciated. Thanx,
Don