Regarding Flexgrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kalps
    New Member
    • Jun 2007
    • 13

    #1

    Regarding Flexgrid

    Hi all,
    I would like to add a new row to MS felx grid when i press enter key in particular row at runtime...Is it possible?? Is anyother control available in VB to do this?please reply....
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    not a good idea using a tradition MS Flex grid to make an editable table. Because MS Flex grid does not support editing directly. U cannot press any key to insert characters into cells like Excel. Some advance versions of Flex Grid (like Video Soft VSFlex Grid) support Editable property, so u can edit cell dirrectly. But your question here is about inserting a new row into Flex Gird, so can u try this code
    Code:
    Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then     ' if u press Enter 
        If MSFlexGrid1.Row = MSFlexGrid1.Rows -1 then    'current row is last row of grid
            MSFlexGrid1.AddItem ""            'insert a new blank row
            MSFlexGrid1.Row = MSFlexGrid1.Row +1           'move curso to new row
            MSFlexGrid1.Col = 1                                          'at the first column
    End If
    End Sub
    this example will work well if your flex grid have one fixed row and one fixed column

    Comment

    • kalps
      New Member
      • Jun 2007
      • 13

      #3
      Originally posted by pureenhanoi
      not a good idea using a tradition MS Flex grid to make an editable table. Because MS Flex grid does not support editing directly. U cannot press any key to insert characters into cells like Excel. Some advance versions of Flex Grid (like Video Soft VSFlex Grid) support Editable property, so u can edit cell dirrectly. But your question here is about inserting a new row into Flex Gird, so can u try this code
      Code:
      Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
      If KeyAscii = vbKeyReturn Then     ' if u press Enter 
          If MSFlexGrid1.Row = MSFlexGrid1.Rows -1 then    'current row is last row of grid
              MSFlexGrid1.AddItem ""            'insert a new blank row
              MSFlexGrid1.Row = MSFlexGrid1.Row +1           'move curso to new row
              MSFlexGrid1.Col = 1                                          'at the first column
      End If
      End Sub
      this example will work well if your flex grid have one fixed row and one fixed column
      [QUOTE]
      Thanks for ur suggestion..its working. but if i try to enter values to flexgrid at run time it is not working...what i did is , i have written code to enter values to flexgrid at run time and embed the code which u gave with it...while running it is able to get values but if i press enter key on row1 and col 1 it is not producing a new row....

      Comment

      Working...