Tina
January 24th, 2000, 08:17 AM
Any ideas on creating a right click menu (like a pop-up) to delete data from a flexgrid ?
|
Click to See Complete Forum and Search --> : Right Click Menu............. Tina January 24th, 2000, 08:17 AM Any ideas on creating a right click menu (like a pop-up) to delete data from a flexgrid ? Aaron Young January 24th, 2000, 11:45 AM 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 ajyoung@pressenter.com aarony@redwingsoftware.com Johnny101 January 24th, 2000, 11:49 AM 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 Tina January 24th, 2000, 01:12 PM How do you create a Sub Menu item ? Aaron Young January 24th, 2000, 01:52 PM 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 ajyoung@pressenter.com aarony@redwingsoftware.com Tina January 24th, 2000, 01:56 PM Thanks ! ! ! codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |