powered by simpleCommunicator - 2.0.58     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / DataGridView.Sort Method (DataGridViewColumn, ListSortDirection)
2 сообщений из 2, страница 1 из 1
DataGridView.Sort Method (DataGridViewColumn, ListSortDirection)
    #38008060
Vova_1805
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Среда 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
...
Рейтинг: 0 / 0
DataGridView.Sort Method (DataGridViewColumn, ListSortDirection)
    #38008078
bazile
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Vova_1805Dim direction As ListSortDirection ' ГЛЮК !!!!!!!!!!!!!!!!!!!!
Что значит "глюк"? Ошибка компиляции? Using System.ComponentModel указан?
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / DataGridView.Sort Method (DataGridViewColumn, ListSortDirection)
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]