Do you want to make the MSFlexGrid control editable?

Source: Internet
Author: User

The contents of each cell in the MSFlexGrid control can not be edited directly by the user, but we can use some small techniques to facilitate the implementation of this editing function to extend the MSFlexGrid application (this is a very common function in practical applications).

You can easily edit the MSFlexGrid control data by just doing the following

Example puts a text box Text1 on a form, and a MSFlexGrid control FLEXGRID1

Add the following example code

Private Sub Form_Load()
   Text1.Move -10000, -10000, 1, 1
End Sub
Private Sub MSFlexGrid1_EnterCell()
   MSFlexGrid1.CellBackColor = vbBlue
   MSFlexGrid1.CellForeColor = vbWhite
   Text1.Text = MSFlexGrid1.Text
   Text1.SelStart = 0
   Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub MSFlexGrid1_LeaveCell()
   MSFlexGrid1.CellBackColor = vbWhite
   MSFlexGrid1.CellForeColor = vbBlue
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
   Text1.SetFocus
End Sub
Private Sub Text1_Change()
   MSFlexGrid1.Text = Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
   Select Case KeyCode
     Case vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown
       KeyCode = 0
   End Select
End Sub

OK, such an editable MSFlexGrid control is complete, simple!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.