good evening folks its me again,
folks i need your help in flexgrid idont know how to use it in editing a database, can you give me some sample program
thanks folks
may god bless you:)
good evening folks its me again,
folks i need your help in flexgrid idont know how to use it in editing a database, can you give me some sample program
thanks folks
may god bless you:)
A compact, practical pattern for that builds on the points from , and : MSFlexGrid is best treated as a display control — it does not provide built‑in, bound in‑place editing like the DataGrid. Two common approaches are (A) use a DataGrid (simpler for bound editing) or (B) use MSFlexGrid for display and implement in‑place edits by overlaying a TextBox and writing the update back to the database. The example below shows approach (B) using ADO: populate the grid from a Recordset, keep the primary key in a hidden column, let the user edit via a TextBox overlay, then commit with an UPDATE.
' Declarations on the form
Private conn As ADODB.Connection
Private rs As ADODB.Recordset
Private editRow As Long, editCol As Long
' Form_Load: open connection and fill grid (keep PK in col 0)
Private Sub Form_Load()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\MyDB.mdb;"
conn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "SELECT ID, FirstName, LastName FROM MyTable", conn, adOpenKeyset, adLockOptimistic
MSFlexGrid1.Rows = 1
Dim r As Long, c As Integer
For c = 0 To rs.Fields.Count - 1
MSFlexGrid1.TextMatrix(0, c) = rs.Fields(c).Name
Next
r = 1
rs.MoveFirst
Do While Not rs.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For c = 0 To rs.Fields.Count - 1
If IsNull(rs.Fields(c).Value) Then
MSFlexGrid1.TextMatrix(r, c) = ""
Else
MSFlexGrid1.TextMatrix(r, c) = rs.Fields(c).Value
End If
Next
rs.MoveNext: r = r + 1
Loop
MSFlexGrid1.ColWidth(0) = 0 ' hide PK
End Sub
' Double-click to show Text1 positioned over the cell
Private Sub MSFlexGrid1_DblClick()
editRow = MSFlexGrid1.Row: editCol = MSFlexGrid1.Col
If editRow > 0 Then
With Text1
.Left = MSFlexGrid1.Left + MSFlexGrid1.ColLeft(editCol)
.Top = MSFlexGrid1.Top + MSFlexGrid1.RowTop(editRow)
.Width = MSFlexGrid1.ColWidth(editCol)
.Text = MSFlexGrid1.TextMatrix(editRow, editCol)
.Visible = True: .SetFocus
End With
End If
End Sub
' Commit edit (Enter or LostFocus)
Private Sub CommitEdit()
If Not Text1.Visible Then Exit Sub
MSFlexGrid1.TextMatrix(editRow, editCol) = Text1.Text
Text1.Visible = False
Dim pkVal As String, fldName As String, sql As String
pkVal = MSFlexGrid1.TextMatrix(editRow, 0)
fldName = rs.Fields(editCol).Name
sql = "UPDATE MyTable SET [" & fldName & "] = '" & Replace(Text1.Text, "'", "''") & "' WHERE ID = " & pkVal
conn.Execute sql
End Sub Notes and cautions:
This pattern keeps the grid display separate from update logic and makes it easy to map rows back to the database via the hidden PK column.
Jump to Post— vb5prgrmr 169You want code? GoTo odesk.com or and put your project up for bid. Don't want to pay? Use your friends who miss you so much! (yahoo, google, ask, answers, bing) Search the world wide web …
You want code? GoTo odesk.com or and put your project up for bid. Don't want to pay? Use your friends who miss you so much! (yahoo, google, ask, answers, bing) Search the world wide web as your answers are out there... The only problem is, is that you have to do the work and don't forget about searching planetsourcecode.com...
Good Luck
try this. project>component>ms flexgrid
then put it into on your form. in properties tab you can connect the flexgrid with database for show the data.
folks what i need is a demonstration
and a explantion can u help me ?
pls repz asap.......:(
folks what i need is a demonstration
and a explantion can u help me ?
pls repz asap.......:(
u can find many example by searching using search engine like www.google.com or yahoo.com
u can put flexgrid vb6 in the search box
there are many sites which provide u with sample and explanation
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.