S
stocki
Hi,
On my WinForm I have a DataGridView, which contains four columns and
four rows. The last row contains only a sum of the values of the cells
of the previous rows in column 3. The cells [3,0], [3,1], [3,2] are
empty ( [row,column] ).
[0,0]="Mr." ; [0,1]="Smith" ; [0,2]="David" ; [0,3]=1000
[1,0]="Mrs."; [1,1]="Fog" ; [1,2]="Denise" ; [1,3]=2000
[2,0]="Mr." ; [2,1]="Ranger"; [2,2]="Stuart" ; [2,3]=3000
[3,0]="" ; [3,1]="" ; [3,2]="" ;
[3,3]=6000
The user clicks on the column header of col 1 and expects the datagrid
to be sorted. As SortMode is set to
DataGridViewColumnSortMode.Programmatic for each column, I do the
sorting within the "dgrdDetails_ColumnHeaderMouseClick" Event. Steps
are as follows:
- Deleting the row with the sum, which is row 3
- Initiating the sort by:
this.dgrdDetails.Sort( this.dgrdDetails.Columns[e.ColumnIndex],
ListSortDirection.Ascending ) ;
Afterwards I wanted to add the row with the sum. Due to the emtpy cell
in col 1, this row appears always as the first row. I recon that the
datagrid is in SortMode still.
So I tried the following right after "this.dgrdDetails.Sort" and
before adding the row with the sum:
for ( int g = 0; g <= this.dgrdDetails.Columns.Count - 1 ; g ++ )
this.dgrdDetails.Columns[g].SortMode =
DataGridViewColumnSortMode.NotSortable ;
Still my summation row appears as the first row. Also setting the
SortMode to "Programmatic" showed any difference.
How can I stop the DataGridView from sorting?
Any hint is highly appreciated!.
Cheers
Stocki
On my WinForm I have a DataGridView, which contains four columns and
four rows. The last row contains only a sum of the values of the cells
of the previous rows in column 3. The cells [3,0], [3,1], [3,2] are
empty ( [row,column] ).
[0,0]="Mr." ; [0,1]="Smith" ; [0,2]="David" ; [0,3]=1000
[1,0]="Mrs."; [1,1]="Fog" ; [1,2]="Denise" ; [1,3]=2000
[2,0]="Mr." ; [2,1]="Ranger"; [2,2]="Stuart" ; [2,3]=3000
[3,0]="" ; [3,1]="" ; [3,2]="" ;
[3,3]=6000
The user clicks on the column header of col 1 and expects the datagrid
to be sorted. As SortMode is set to
DataGridViewColumnSortMode.Programmatic for each column, I do the
sorting within the "dgrdDetails_ColumnHeaderMouseClick" Event. Steps
are as follows:
- Deleting the row with the sum, which is row 3
- Initiating the sort by:
this.dgrdDetails.Sort( this.dgrdDetails.Columns[e.ColumnIndex],
ListSortDirection.Ascending ) ;
Afterwards I wanted to add the row with the sum. Due to the emtpy cell
in col 1, this row appears always as the first row. I recon that the
datagrid is in SortMode still.
So I tried the following right after "this.dgrdDetails.Sort" and
before adding the row with the sum:
for ( int g = 0; g <= this.dgrdDetails.Columns.Count - 1 ; g ++ )
this.dgrdDetails.Columns[g].SortMode =
DataGridViewColumnSortMode.NotSortable ;
Still my summation row appears as the first row. Also setting the
SortMode to "Programmatic" showed any difference.
How can I stop the DataGridView from sorting?
Any hint is highly appreciated!.
Cheers
Stocki