Results 1 to 4 of 4

Thread: Want to write in FlexGrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Dhaka, Bangladesh
    Posts
    102

    Want to write in FlexGrid

    How I can input my entry/write my values in a FlexGrid as I can do that in textbox ?

    I want to input my values in database from FlexGrid column. and users of my application want to write the values in FlexGrid rather than textbox or other input tools?

    Did you understand my problem ? How I can solve it ?

    Rajib

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Want to write in FlexGrid

    Flex grid cannot natively be edited by a user.

    We use a trick of floating a textbox onto the cell that is clicked on.

    Search the forum for "flxinput" - you will find threads and posts by me relating to this.

    MartinLiss also has other tricks for allowing edit of a cell - not as robust as a textbox, but gets the job done. I believe he has links to this in his signature - find a post by him to follow that idea.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Want to write in FlexGrid

    I agree but you may try this:

    (You'll need a Flaxgirs and a textbox to do this)

    VB Code:
    1. Option Explicit
    2.  
    3. ' to store the row/column of the cell
    4. ' being edited
    5. Dim m_lCellCol As Long
    6. Dim m_lCellRow As Long
    7.  
    8. Private Sub Form_Load()
    9.   m_lCellRow = -1
    10.   m_lCellCol = -1
    11.   txtCell.BorderStyle = 0
    12.   txtCell.Visible = False
    13.   ' set the text background color to the
    14.   ' backcolor of the tooltip text to make
    15.   ' the cell being edited having a different color
    16.   txtCell.BackColor = vbInfoBackground
    17.   MSFlexGrid1.Cols = 10
    18.   MSFlexGrid1.Rows = 10
    19. End Sub
    20.  
    21. Private Sub MSFlexGrid1_DblClick()
    22.   showTxtCell
    23. End Sub
    24.  
    25. Private Sub MSFlexGrid1_RowColChange()
    26.   removeTxtCell
    27. End Sub
    28.  
    29. Private Sub MSFlexGrid1_Scroll()
    30.   removeTxtCell
    31. End Sub
    32.  
    33. Private Sub MSFlexGrid1_SelChange()
    34.   removeTxtCell
    35. End Sub
    36.  
    37. Private Sub txtCell_Change()
    38.   MSFlexGrid1.Text = txtCell.Text
    39. End Sub
    40.  
    41. Private Sub showTxtCell()
    42.   If m_lCellRow = -1 Then
    43.     With MSFlexGrid1
    44.       ' store the current row and column
    45.       m_lCellRow = .Row
    46.       m_lCellCol = .Col
    47.       ' move the textbox to the correct cell
    48.       txtCell.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
    49.       txtCell.Text = .Text
    50.       ' select all text
    51.       txtCell.SelLength = Len(.Text)
    52.     End With
    53.     txtCell.Visible = True
    54.     txtCell.SetFocus
    55.   End If
    56. End Sub
    57.  
    58. Private Sub removeTxtCell()
    59.   If m_lCellRow <> -1 Then
    60.     MSFlexGrid1.TextMatrix(m_lCellRow, m_lCellCol) = txtCell.Text
    61.     m_lCellRow = -1
    62.     m_lCellCol = -1
    63.     txtCell.Visible = False
    64.   End If
    65. End Sub
    66.  
    67. Private Sub txtCell_Validate(Cancel As Boolean)
    68.   removeTxtCell
    69. End Sub

    Note: I did not make this, I found it but it may be what you want.


    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Want to write in FlexGrid

    That is very similar to our technique - nice.

    The problems always arise with how to handle to odd aspects - like scrolling and moving the textbox - or as you chose, removing the textbox on scroll.

    Validation of textbox data is always an issue as well.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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