|
-
January 24th, 2000, 09:17 AM
#1
Right Click Menu.............
Any ideas on creating a right click menu (like a pop-up) to delete data from a flexgrid ?
-
January 24th, 2000, 12:45 PM
#2
Re: Right Click Menu.............
Create the Menu using the Menu Editor and set its Visible Property to False, then call it using:
PopupMenu MenuName
Example:
Create a menu called mnuFlexPopup, set its Visible Property to False, create a Sub Menu Item Called mnuClearCell, then paste this code:
private Sub Form_Load()
Dim iX as Integer
Dim iY as Integer
'Generate some Dummy Data
With MSFlexGrid1
.FixedCols = 0
.FixedRows = 0
.Rows = 5
.Cols = 4
for iY = 0 to .Rows - 1
for iX = 0 to .Cols - 1
.TextMatrix(iY, iX) = Rnd * 100
next
next
End With
End Sub
private Sub mnuClearCell_Click()
'Clear the Specified Cell
With MSFlexGrid1
.TextMatrix(.Tag, .RowData(.Tag)) = ""
End With
End Sub
private Sub MSFlexGrid1_MouseUp(Button as Integer, Shift as Integer, x as Single, y as Single)
With MSFlexGrid1
'Verify Mouse is over a Row
If .RowPos(.MouseRow) + .RowHeight(.MouseRow) > y then
'Verify Mouse is over a Column
If .ColPos(.MouseCol) + .ColWidth(.MouseCol) > x then
If Button = vbRightButton then
'Store the Row in the Tag property
.Tag = .MouseRow
'Store the Column in the Rows Data property
.RowData(.MouseRow) = .MouseCol
'Show the PopupMenu
PopupMenu mnuFlexPopup
End If
End If
End If
End With
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
January 24th, 2000, 12:49 PM
#3
Re: Right Click Menu.............
The idea that comes to my mind first would be, add a hidden menu on the form with the flexgrid on it. Then in the FlexGrid1_MouseDown event place the folowing code:
private Sub FlexGrid1_MouseMove(Button as Integer, Shift as Integer, X as Long, Y as Long)
If Button = vbRightButton then
'select the row that was clicked in the grid
'I personally don't work with the Flexgrid, so I'm not 100% sure that
'the following line of code will work - but something similar to this
'should be done.
FlexGrid1.Row = FlexGrid1.RowContaining(X)
'show the menu with the delete option etc...
PopupMenu mnuRightClickMenu
End If
End Sub
I hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
January 24th, 2000, 02:12 PM
#4
Re: Right Click Menu.............
How do you create a Sub Menu item ?
-
January 24th, 2000, 02:52 PM
#5
Re: Right Click Menu.............
After Entering in your Main Menu Item and Click Next in the MenuEditor, click the Right Arrow, to Indent the Next Entry, creating a SubMenu Item of that Menu Item, so that the List in the Menu Editor Looks like this:
File
.. Clear Cell
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
January 24th, 2000, 02:56 PM
#6
Re: Right Click Menu.............
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|