CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Posts
    105

    How to add a row of data in MSFlexgrid

    Hi all

    I am fetching data from ms access into MS flex grid using ADOs. Now i want to add some rows of data into Flexgrid. Also i want to save the same data into access table. How it is possible.

    I can add empty row by using

    MSFlexGrid1.AddItem "", MSFlexGrid1.RowSel

    but i want add field data also

    regards

  2. #2
    Join Date
    Nov 2004
    Posts
    105

    Re: How to add a row of data in MSFlexgrid

    Hai

    I got one solution to add data at the end of Datagrid using input Box with following code

    For lcol = 1 To lfieldcnt
    sFieldname(lcol) = InputBox(vColName(lcol))
    MSFlexGrid1.Col = MSFlexGrid1.Col + 1
    MSFlexGrid1.Text = sFieldname(lcol)
    Next lcol

    but i want to add directly with out input box.

    And also i want to save this into ms access database. where i am using ADO. how to add, i mean save it into access

    regards
    Ravi

  3. #3
    Join Date
    Sep 2004
    Posts
    265

    Re: How to add a row of data in MSFlexgrid

    I don't think the above code add the data at the end of the grid !!!

    If you want to enter values into the grid , u can refer the "EnterCell" and "LeaveCell" events in MSDN.

    As for saving the data, U can just read the data from the grid and save it into the database (also available in MSDN)

  4. #4
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: How to add a row of data in MSFlexgrid

    If you are not familiar with the search function in this forum you should try it - there is a drop down button at the top right called "Search this forum"

    Click on this and key "MSFLEXGRID" into the search - you will be amazed at what you will find (normally a lot more than you specifically asked for) !!!



    Have a look at posts on Msflexgrid

    eg

    Headings
    http://www.codeguru.com/forum/showth...ght=msflexgrid

    Adding Rows to a Grid - Changing Colour of a Cell
    http://www.codeguru.com/forum/showth...ght=msflexgrid

    Good hunting

  5. #5
    Join Date
    Feb 2005
    Posts
    131

    Thumbs up Re: How to add a row of data in MSFlexgrid

    You can add a row in msflexgrid with this line

    msflexgrid.additem field1 & vbtab & field2 & vbtab & field3,msflexgrid.rowsel

    Hope this will work for you

  6. #6
    Join Date
    Nov 2004
    Posts
    105

    Re: How to add a row of data in MSFlexgrid

    Yes I can add, But I want to add at the end of the flexgrid,if i click on flexgrid cell i have to add data there just like addind data in Excel sheet. is it possible, I can add data at the end of flex grid by using Inputbox
    i am posting code here

    Private Sub cmdAdd_Click()
    Dim lfieldcnt As Long
    Dim lcol As Long
    Dim sFieldname() As String
    Dim vColName As Variant
    Dim lrecCount As Long

    lfieldcnt = clsTree.FieldCount ' total field count
    ReDim sFieldname(lfieldcnt)
    vColName = clsTree.ColumnName ' name of the column
    lrecCount = clsTree.RecordCount ' record count
    MSFlexGrid1.Col = 0
    MSFlexGrid1.Row = lrecCount
    MSFlexGrid1.AddItem ""
    lrecCount = lrecCount + 1
    MSFlexGrid1.Row = lrecCount
    For lcol = 1 To lfieldcnt
    sFieldname(lcol) = InputBox(vColName(lcol))
    'sFieldname(lcol) = MSFlexGrid1.TextArray(6)
    MSFlexGrid1.Col = MSFlexGrid1.Col + 1
    MSFlexGrid1.Text = sFieldname(lcol)
    Next lcol
    End Sub


    any clues

    thanks and rgards
    Ravi

  7. #7
    Join Date
    Jun 2005
    Posts
    12

    Re: How to add a row of data in MSFlexgrid

    u can use a text box with the grid to enter the text in the cell..initially the text box will be invisible and in the grid's click event u can make it visible and bring the focus to the text box..
    and also in the grid's entercell event write this code..

    txtgrid.Top = grid.Top + grid.CellTop
    txtgrid.Left = grid.Left + grid.CellLeft
    txtgrid.Width = grid.CellWidth
    txtgrid.Height = grid.CellHeight

    If LTrim(RTrim(grid.Text)) <> "0" Then
    txtgrid.Text = LTrim(grid.Text)
    Else
    txtgrid.Text = ""
    End If
    txtgrid.Visible = True
    txtgrid.SetFocus

    where gridtxt is the name of text box and viewgrid is the grid's name..

    and in the grid's leave cell event write this..

    grid.Text = Str(Val(txtgrid.Text)).

    hope this vil help..

  8. #8
    Join Date
    Nov 2004
    Posts
    105

    Re: How to add a row of data in MSFlexgrid

    Thankyou
    I will try with that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured