borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (store procedure and VB?)Next Topic (DELAY FUNCTION) New Topic New Poll Post Reply
AndreaVB Forum : Database : Regarding FlexGrid Solved Topic
Poster Message
chintu4u
Level: Graduate

Registered: 22-03-2006
Posts: 11

icon Regarding FlexGrid

Hi can any body give example of FlexGrid.

Exactly : I want to display data from my DB to FlexGrid as I run my app. also if I add new entry in my DB it sholud be updated in the grid...

plz help me out.

29-05-2006 at 05:54 AM
View Profile Send Email to User Show All Posts | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Regarding FlexGrid

Hello. What help do you need?

Anyway, a sample code would be:
    Dim rs As ADOBD.Recordset
    Dim sql As String
    Dim rsRow As Long, col As Long
    ' build the sql instruction
    sql = "SELECT * FROM MyTable"
    ' open the recordset
    Set rs = New ADODB.Recordset
    rs.Open sql, cn, adForwardOnly, adLockPessimistic, adCmdText
    If Not (rs.BOF And rs.EOF) Then
        ' set the grid size
        grdMyFlexGrid.Rows = rs.RecordCount + 1
        grdMyFlexGrid.FixedRows = 1
        grdMyFlexGrid.Cols = rs.Fields.Count + 1
        grdMyFlexGrid.FixedCols = 1
        grdMyFlexGrid.ColWidth(0) = 300
        ' loop the recordset
        Do While Not rs.EOF
            rsRow = rsRow + 1
            ' the ID value can be stored into the RowData property
            grdMyFlexGrid.RowData(rsRow) = rs.Fields("IDField").Value
            ' fill the grid cells with the current record values
            For col = 0 To rs.Fields.Count - 1
                grdMyFlexGrid.TextMatrix(rsRow, col + 1)
            Next col
            rs.MoveNext
        Loop
    End If
    ' close and destroy the recordset
    rs.Close
    Set rs = Nothing

Remember that a MSFlexGrid is always a read-only control, so you can't provide user the ability to directly change values into it: values can only be changed by code. In order to do it, there are some tricks by using an hidden textbox, placing it over the cell and showing it, and then passing its text to the underlying cell.

Ask more for whatever is unclear.

[Edited by yronium on 21-06-2006 at 09:59 AM GMT]

____________________________
Real Programmer can count up to 1024 on his fingers

30-05-2006 at 11:48 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Regarding FlexGrid Solved Topic
Previous Topic (store procedure and VB?)Next Topic (DELAY FUNCTION) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder