by melecio a. adarlo jr (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 5th April 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Editable MsFlexGrid, can add new row and remove row
'Shift click to add new row
'Ctrl click to reove row
'Requirement MsFlexGrid
Private Sub Flex1_DblClick()
Text1.Text = Flex1.Text
Text1.Left = Flex1.Left + Flex1.CellLeft
Text1.Top = Flex1.Top + Flex1.CellTop
Text1.Height = Flex1.CellHeight
Text1.Width = Flex1.CellWidth
Text1.Visible = True
Text1.SetFocus
End Sub
Private Sub Flex1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 And Shift = 1 Then
Flex1.Rows = Flex1.Rows + 1
End If
If Button = 1 And Shift = 2 Then
If Flex1.Rows > 2 Then
If MsgBox("Remove this row?", vbYesNo) = vbYes Then
Flex1.RemoveItem (Flex1.row)
End If
Else
MsgBox "Cannot delete row"
End If
End If
End Sub
Private Sub Form_Load()
Dim ctr As Integer
For ctr = 0 To 5
FlexXY Flex1, ctr, 0, "Column" + Str(ctr)
Next
End Sub
Private Sub FlexXY(flex As MSFlexGrid, col As Integer, row As Integer, txt As String)
flex.col = col
flex.row = row
flex.Text = txt
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
Flex1.Text = Text1.Text
Flex1.SetFocus
Text1.Visible = False
End Sub