Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSHFLEXGRID RIGHT MOUSE FOCUS 1

Status
Not open for further replies.

joeschoe

Programmer
Jan 13, 2002
67
0
0
IL
When right clicking in a cell, I require the cell to change background color.
If the cell is already selected, the color change works well.
If I right click on any other cell, the change still happens to the originally selected cell.
If I use the left click, the cell selection changes to the cell I clicked and the color changes correctly.
I want to use the left button to highlight the cell for data input and the right button to change the color.
Is this an intrisic flaw in mshflexgrid? is there an easy fix?

I have tried in mousedown, mouseup and doubleclick, all to no avail.
 
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
MSHFlexGrid1.Row = MSHFlexGrid1.MouseRow
MSHFlexGrid1.Col = MSHFlexGrid1.MouseCol
MSHFlexGrid1.CellBackColor = vbRed
End If
End Sub
 
Thanks, this is a bit better:

Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngBackColor As Long

If Button = vbRightButton Then
With MSHFlexGrid1
If .MouseRow >= .FixedRows Then
If .MouseCol >= .FixedCols Then
lngBackColor = .BackColor
.Row = .MouseRow
.Col = .MouseCol
.CellBackColor = IIf(.CellBackColor = vbRed, lngBackColor, vbRed)
End If
End If
End With
End If
End Sub

vladk
 
Nice logic vladk,
I like the " >= " which caters for the stupid numbering of column and rows from 0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top