Solved

How can I make a FlexGrid editable???

Posted on 2000-04-06
7
181 Views
Last Modified: 2010-05-02
Hi,

I'm using the following code to create and populate a felxgrid with information from an Access DB. Can anyone please tell me how to edit the code in order to make the Grid editable. i.e I want to be able to update the info in the Db Table from my form.

Any help or suggestions would be greatly appreciated.
cheers,
ian


Set rs1 = New adodb.Recordset        'create recordset
    rs1.Open "select * from AdministratorPasswords", conn, adOpenKeyset,     adLockOptimistic                             'populate rs with query result


mfgFlex1.Clear 'set grid layout at run-time
    k = rs1.RecordCount
    j = rs1.Fields.Count
    mfgFlex1.Rows = k + 1
    mfgFlex1.Cols = j + 1
   
    With mfgFlex1
        lngRow = 1
        Do Until rs1.EOF
            mfgFlex1.TextMatrix(0, 1) = "Username"
            mfgFlex1.TextMatrix(0, 2) = "Password"
            For lngCol = 0 To rs1.Fields.Count - 1
                .TextMatrix(lngRow, lngCol + 1) = rs1(lngCol)
            Next lngCol
            rs1.MoveNext
            lngRow = lngRow + 1
        Loop
    End With
0
Comment
Question by:shovels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2690506
you will need to create an invisible textbox that moves to the desired cell location and becomes visible when you want to edit the grid
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2690510
rather than post all the code just see this article:
http://msdn.microsoft.com/library/techart/msdn_msflexgrid.htm

cheers!
0
 
LVL 6

Expert Comment

by:Marine
ID: 2690716
as another person mantioned, flexgrid is read-only by default therefore you cannot edit it. You can get around it by placing the textbox into each cell when you click in it. And depending on the cell you click you would place a textbox in there.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 4

Expert Comment

by:Nazdor
ID: 2692487
Try using a DataGrid instead.

Add an ADO datasource, assign the DataGrid to it, load the datasource's recordset accordingly (which auto loads into the datagrid).  You can lock columns you don't want people to edit etc.

However, I've found it a bit clunky... :-(  So you're probably better off dealing with the extra code and sticking with your flexgrid...
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 2692708
Hi!

The various grids are quite poor in VB from a user edit perspective.

Upgrade to TrueDBGrid is a good start!

I usually Pop up Record Edit forms by clicking an Edit button - allowing edit of the Selected record and close control of what the user is doing.

With the datagrids selecting a record moves the record so its easy to edit the underlying record.

Editing in the grid is clunky and difficult for the user (my opinion only!) nad difficult to control.

Good Luck

Voodoman!


0
 
LVL 1

Accepted Solution

by:
mr_krishna earned 50 total points
ID: 2693468
Put a TextBox control in the form and write the following code. There is no other way to make flexigrid is editable.

With flexgrid1
      If .Col = 2 And .Row <> .Rows - 1 Then
         bCellEdit = True
         txtCell.Top = .Top + .CellTop - 50
         txtCell.Left = .Left + .CellLeft - 50
         txtCell.Height = .CellHeight
         txtCell.Width = .CellWidth + 30
         iLastRow = .Row
         txtCell = .Text
         txtCell.Visible = True
         txtCell.SetFocus
      End If
   End With
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2693528
mr krishna that is what my link tells him, in detail the procedure to use that method
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question