Results 1 to 4 of 4

Thread: how to make the field of a gridcontrol sortable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2024
    Posts
    72

    how to make the field of a gridcontrol sortable

    Hello

    here is my code and i want to sort the aktiv and name columns in my rangegridcontrol sortbar. how to do this?

    Code:
    Private _SortBestandColumn As Integer
    Private _SortBestandDirection As ListSortDirection
    
    Private Shared ReadOnly HeaderBestand As String() = New String() {L("Aktiv"), L("Name")}
    Private Sub InitGridBestand()
        rgBestand.Clear()
    
        _SortBestandColumn = 0
        _SortBestandDirection = ListSortDirection.Ascending
    
        _rngHeaderBestand = rgBestand.Add(0, 0, 0, HeaderBestand.Length - 1)
        _rngHeaderBestand.Top = 0
        _rngHeaderBestand.Left = 1
        _rngHeaderBestand.RowHeight(0) = rgBestand.DefaultHeaderRowHeight
        _rngHeaderBestand.HorizontalAlignment = GridHorizontalAlignment.Center
        _rngHeaderBestand.Getter = Function(Row, Column) HeaderBestand(Column)
        _rngHeaderBestand.SortHeader = True
        _rngHeaderBestand.SortDirection = Function(Row, Column) If(Column = _SortBestandColumn, _SortBestandDirection, New ListSortDirection?)
        _rngHeaderBestand.ColWidth(0) = 65
        _rngHeaderBestand.ColWidth(1) = 160
    
        Dim rngAktiv = rgBestand.Add(0, _BestandsEigenschaften.Count - 1, 0, 0)
        rngAktiv.TopNeighbour = _rngHeaderBestand
        rngAktiv.Left = 1
        rngAktiv.HorizontalAlignment = GridHorizontalAlignment.Center
        rngAktiv.VerticalAlignment = GridVerticalAlignment.Middle
        rngAktiv.CheckBox = True
        rngAktiv.Getter = Function(Row, Column) _Bestands.Contains(_BestandsEigenschaften(Row))
        rngAktiv.Setter = Sub(Row, Column, Value)
                              Dim isChecked = ParseNullableBoolean(Value).GetValueOrDefault(False)
                              If isChecked Then
                                  _Bestands.Add(_BestandsEigenschaften(Row))
                              Else
                                  _Bestands.Remove(_BestandsEigenschaften(Row))
                              End If
                          End Sub
    
        Dim rngName = rgBestand.Add(0, _BestandsEigenschaften.Count - 1, 0, 0)
        rngName.TopNeighbour = _rngHeaderBestand
        rngName.LeftNeighbour = rngAktiv
        rngName.Getter = Function(Row, Column) _BestandsEigenschaften(Row)
        rngName.Enabled = RangeGridControl.None
    
    
        rgBestand.InitGrid()
        rgBestand.FillGrid()
    End Sub
    
    Private Sub rgBestand_SortOrderChanged(sender As Object, e As SortOrderChangedEventArgs) Handles rgBestand.SortOrderChanged
        If _SortBestandColumn <> e.Column Then
            _SortBestandColumn = e.Column
            _SortBestandDirection = ListSortDirection.Ascending
        Else
            If _SortBestandDirection = ListSortDirection.Ascending Then
                _SortBestandDirection = ListSortDirection.Descending
            Else
                _SortBestandDirection = ListSortDirection.Ascending
            End If
        End If
        UpdateBestandSort()
    End Sub
    i don't know how to complete UpdateBestandSort() method?

    thank you
    Last edited by jmcilhinney; Jul 29th, 2024 at 09:31 AM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,657

    Re: how to make the field of a gridcontrol sortable

    What type of control is a rangegridcontrol?

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,657

    Re: how to make the field of a gridcontrol sortable

    Typically, you'd assign a custom sorter class. A class that implements IComparer

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,657

    Re: how to make the field of a gridcontrol sortable


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width