Use FlexGrid's Entercell method to implement controls editable

xiaoxiao2021-03-06  170

The content of each Cell grid in the MSFlexGRID control is not directly edited by the user, but we can easily implement this editing function through some small techniques to extend the application of MSFlexGrid (this is a very common function in practical applications).

You only need to make the function of editing the MSFlexGrid control data by pressing the following.

In the form, put a text box text1, and a MSFLEXGRID control FlexGrid1

Add to the following code

Private sub flow_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)

Select Case Keycode

Case VBKEYEFT, VBKEYRIGHT, VBKEYUP, VBKEYDOWN

Keycode = 0

End SELECT

End Sub

OK, such an editable MSFLEXGRID control is complete!

转载请注明原文地址:https://www.9cbs.com/read-128136.html

New Post(0)