Results 1 to 5 of 5

Thread: grid

  1. #1

    Thread Starter
    Junior Member Gold4tune's Avatar
    Join Date
    Apr 2001
    Location
    Québec
    Posts
    19

    Angry

    Somebody know if we can allow the user to enter data in MSFlexGrid. If not, witch control (like a grid) I have to use.

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    You need to place a text box over the cell clicked into, and get the user to type the entry into this. When the focus is lost from the text box, the entry is updated :
    Code:
    Private Type FlxCell
        row As Long
        col As Long
    End Type
        'Set up a new type used to define a cell in the flexgrid
        '- this includes 2 number variables, to reference in the row & column.
    
    Private Active_FlxCell As FlxCell
        'Introduce new variable for above created cell / new type.
    
    
    Private Sub FlxGrd_dblClick()
         If FlxGrd.row > 0 And FlxGrd.col = 2 Then
            Active_FlxCell.row = FlxGrd.row
            Active_FlxCell.col = FlxGrd.col
            'If a cell is selected, check if this is the top row (which would be the heading)
            FlxGrd.ScrollBars = flexScrollBarNone
            'User can't scroll down until the cell has been unselected.
            
            With TxtEdit
                .Top = FlxGrd.CellTop + FlxGrd.Top
                .Left = FlxGrd.CellLeft + FlxGrd.Left
                .Width = FlxGrd.CellWidth
                .Text = FlxGrd.Text
                .Visible = True
                .ZOrder
                .SetFocus
            End With
            'Set the size of the textbox to fit around the selected cell, make it 
            'visible for the user to see, and copy the active cell's text inside the text box.
        End If
    End Sub
    
    Private Sub TxtEdit_LostFocus()
        FlxGrd.ScrollBars = flexScrollBarBoth
        'Place scrollbars back onto the Flexgrid control.
    
        If Not IsNull(TxtEdit.Text) Then
        'user typed an entry in the text box
            FlxGrd.TextMatrix(Active_FlxCell.row, Active_FlxCell.col) = TxtEdit.Text
        End If
    End Sub
    This is what I used. If you look in the MSDN samples that come with VB, there a project called MSFlexgd.vbp, which is a sample app of using the flexgrid control
    Last edited by alex_read; Apr 17th, 2001 at 10:59 AM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Junior Member Gold4tune's Avatar
    Join Date
    Apr 2001
    Location
    Québec
    Posts
    19

    Thumbs up thx but...

    thank you, it's exactly what i want!!!

    But I still have a question.
    I can't change the width of my cells...
    And can the cells have different size than the others???

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    You need to do this in your code at startup. I.e. -
    Code:
     Private Sub Form_Load()
        With MSFlexGrid1
            .ColWidth(0) = 1000
            .ColWidth(1) = 1000
            .ColWidth(2) = 1000
        End With
    End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5

    Thread Starter
    Junior Member Gold4tune's Avatar
    Join Date
    Apr 2001
    Location
    Québec
    Posts
    19

    Talking thx

    I have a simple question....
    Why I haven't found it alone...

    Thanks!!!

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