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

FillFlexGrid - Routine to fill flexgrid from ADO recordset

Total Hit ( 3674)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The following routine takes 2 arguments, ADO recordset and flexgrid which you want to fill.

Click here to copy the following block
Sub FillFlexgrid(rst As ADODB.Recordset, msfGrid As MSFlexGrid)
  Dim cln As Field
  With msfGrid
    .Rows = 2
    .Cols = rst.Fields.Count
    'get the number of grid cols
    .FixedRows = 1
    .FixedCols = 0
    .Row = 0
    .Col = 0
    For Each cln In rst.Fields
      .Text = cln.Name
      'populate header row with names of fields
      If .Col < .Cols - 1 Then .Col = .Col + 1
    Next
    Do While Not rst.EOF
      'loop thru recordset to populate grid
      .Row = rst.AbsolutePosition
      'move to the next row
      .Col = 0
      'reset ourselves back to column(0)
      For Each cln In rst.Fields
        If Not IsNull(cln.Value) Then
          .Text = Trim(CStr(cln.Value))
        Else
          .Text = ""
        End If
        If .Col < .Cols - 1 Then .Col = .Col + 1
      Next
      rst.MoveNext
      .Rows = .Rows + 1
      'add a new row to the grid
    Loop
    .Rows = .Rows - 1
    'remove the last row because it's blank
    .Row = 0
  End With

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.