glerner
March 21st, 2001, 09:20 PM
Is there a way to put an indicator on a row header (up or down) that shows which column grid is sorted (ascending/descending - similar to Windows Explorer)?
Thanks,
Glenn
Thanks,
Glenn
|
Click to See Complete Forum and Search --> : Flexgrid sort indicator glerner March 21st, 2001, 09:20 PM Is there a way to put an indicator on a row header (up or down) that shows which column grid is sorted (ascending/descending - similar to Windows Explorer)? Thanks, Glenn Iouri March 22nd, 2001, 07:24 AM Here is an example which will put ^ or v on a sorted column ' Useful for sorting da es and other occassions where you have ' to click on one column but sort by another ' ' Inputs:'TheForm is the form where you want the 'sorter works, usually its Me. 'ClickCol is the column # that is being clicked 'on and SortCol is the column # that will be 'sorted. 'ParamArray is an array of Booleans that represents how you want each column sorted. True means sort as a string, False means sort as numeric, and if you omit the paramter then it is sorted as generic. Example True,True,,False means the first two columns are sorted as a string the third column is sorted as generic, and the fourth is sorted as numeric. In this case if there is more than 4 columns then the rest would get sorted as generic since their parameter is missing. The IsString array represents how you want each column sorted. True means sort as a string, False means sort as numeric, and if you omit the paramter then it is sorted as generic. '' Example True,True,,False means the first two columns are sorted as a string the third column is sorted as generic and the fourth is sorted as numeric. Public Sub SortFlex(TheForm As Form, FlexGrid As MSFlexGrid, ClickCol As Integer, SortCol As Integer, ParamArray IsString() As Variant) Dim i As Integer Dim Headline As String Dim Ascend As Boolean Dim Decend As Boolean Const p As String = "^" Const m As String = "v" On Error Goto SortErr TheForm.MousePointer = vbHourglass FlexGrid.Col = SortCol 'cycle thru all the columns 'example Call SortFlex(Me, MSFlexGrid1, MSFlexGrid1.Col, MSFlexGrid1.Col) For i = 0 To FlexGrid.Cols - 1 Headline = FlexGrid.TextMatrix(0, i) Ascend = Right(Headline, 1) = p Decend = Right(Headline, 1) = m If Ascend Or Decend Then Headline = Left(Headline, Len(Headline) - 1) If i = ClickCol Then If Ascend Then FlexGrid.TextMatrix(0, ClickCol) = Headline & m If UBound(IsString) < LBound(IsString) Then FlexGrid.Sort = flexSortGenericDescending Else If IsString(i) Then FlexGrid.Sort = flexSortStringDescending Else FlexGrid.Sort = flexSortNumericDescending End If End If Else FlexGrid.TextMatrix(0, ClickCol) = Headline & p If UBound(IsString) < LBound(IsString) Then FlexGrid.Sort = flexSortGenericAscending Else If IsString(i) Then FlexGrid.Sort = flexSortStringAscending Else FlexGrid.Sort = flexSortNumericAscending End If End If End If Else FlexGrid.TextMatrix(0, i) = Headline End If Next i SortErr: TheForm.MousePointer = vbNormal If Err.Number <> 0 Then MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Sort Error" End If End Sub Iouri Boutchkine iouri@hotsheet.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |