|
DataGridView.Sort Method (DataGridViewColumn, ListSortDirection)
|
|||
---|---|---|---|
#18+
Среда Visual Basic Visial STUDIO’2010 Professional MSDN'2008: The following code example demonstrates how to use the Sort in a programmatic sort авторPrivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' from MSDN'2008: The following code example demonstrates how ' to use the Sort in a programmatic sort. ' Example НЕ КОРРЕКТЕН! имеется error ! ' Check which column is selected, otherwise set NewColumn to Nothing. Dim newColumn As DataGridViewColumn If OrdersDataGridView.Columns.GetColumnCount(DataGridViewElementStates _ .Selected) = 1 Then newColumn = OrdersDataGridView.SelectedColumns(0) Else newColumn = Nothing End If Dim oldColumn As DataGridViewColumn = OrdersDataGridView.SortedColumn Dim direction As ListSortDirection ' ГЛЮК !!!!!!!!!!!!!!!!!!!! ' If oldColumn is null, then the DataGridView is not currently sorted. If oldColumn IsNot Nothing Then ' Sort the same column again, reversing the SortOrder. If oldColumn Is newColumn AndAlso OrdersDataGridView.SortOrder = _ SortOrder.Ascending Then direction = ListSortDirection.Descending Else ' Sort a new column and remove the old SortGlyph. direction = ListSortDirection.Ascending oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None End If Else direction = ListSortDirection.Ascending End If ' If no column has been selected, display an error dialog box. If newColumn Is Nothing Then MessageBox.Show("Select a single column and try again.", _ "Error: Invalid Selection", MessageBoxButtons.OK, _ MessageBoxIcon.Error) Else OrdersDataGridView.Sort(newColumn, direction) If direction = ListSortDirection.Ascending Then newColumn.HeaderCell.SortGlyphDirection = SortOrder.Ascending Else newColumn.HeaderCell.SortGlyphDirection = SortOrder.Descending End If End If End Sub ... |
|||
:
Нравится:
Не нравится:
|
|||
22.10.2012, 13:25 |
|
|
start [/forum/topic.php?fid=20&fpage=191&tid=1405767]: |
0ms |
get settings: |
10ms |
get forum list: |
14ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
29ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
46ms |
get tp. blocked users: |
2ms |
others: | 312ms |
total: | 436ms |
0 / 0 |