Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Sort data in MS Flex grid by clicking the column

Total Hit ( 3084)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
Option Explicit

'Imagine that data has retrived in The MS Flex Grid.
'How on clicking in the list view we can sort the data like wise we can do
'with the flex grid also.
'     
'     the property used is Mousecol of Flexgrid.
'     
'     for the code to work place a Flex grid on the form
'     
'Code:
     
Private Sub Form_Load()
  Dim Str As String
  Dim i As Integer
  Dim j As Integer

  i = 0: j = 0
  MSFlexGrid1.Rows = 1
  Randomize
  For i = 1 To Int(Rnd() * 10) + 1
    Str = ""
    For j = 1 To 10
      Str = Str & Chr(65 + Int(Rnd() * 26))
    Next
    MSFlexGrid1.AddItem Int(Rnd() * 100) & vbTab & Str
  Next
End Sub

Private Sub MSFlexGrid1_Click()
  Call FlexSort("A")
End Sub

Private Sub MSFlexGrid1_DblClick()
  Call FlexSort("D")
End Sub

Sub FlexSort(Mode As String)
  If MSFlexGrid1.Row = 1 Then
    If MSFlexGrid1.MouseCol = 0 Then
      MSFlexGrid1.Col = 0
      If Mode = "A" Then
        MSFlexGrid1.Sort = flexSortNumericAscending
      Else
        MSFlexGrid1.Sort = flexSortNumericDescending
      End If
    ElseIf MSFlexGrid1.MouseCol = 1 Then
      MSFlexGrid1.Col = 1
      If Mode = "A" Then
        MSFlexGrid1.Sort = flexSortStringAscending
      Else
        MSFlexGrid1.Sort = flexSortStringDescending
      End If
    End If
  End If
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.