[RESOLVED] VB6 - Can you make MSHFlexGrid cell have a click effect
Hi,
I was wondering if it would be possible to make a cell in a MSHFlexGrid act like it has been clicked (similar to a button click). For example if I had a pictureBox control that has it's appearance property set to 0 - Flat. I can add the following code to create a click effect:
Private Sub Picture1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Picture1.Appearance = 1 '3D
End Sub
Private Sub Picture1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Picture1.Appearance = 0 'Flat
End Sub
Does anyone know if you can do something similar to a cell in a flexgrid?
Kind Regards
Re: VB6 - Can you make MSHFlexGrid cell have a click effect
Place another control (e.g frame or textbox) on top of the cell and then use its clic.
This will require you to position the control at that specific cell and then show the underlying cell contents in the overlay control -- if you want the underlying value to show.
Re: VB6 - Can you make MSHFlexGrid cell have a click effect
You cannot change individual Cell borders but you could simply change its background colour.
This only works if the FocusRect property is set to flexFocusLight or flexFocusHeavy and the SelectionMode set to flexSelectionFree
Code:
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColorFixed
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor
End Sub
If required, add code to check if the user is clicking on cell and not on a Fixed column or outside the grid area.
Re: VB6 - Can you make MSHFlexGrid cell have a click effect
Thanks for your replys. I've managed to sort this now. I used 2 picturebox controls and selected 2 similar images one that looked slightly darker and indented to give the impression that cell had been clicked. I used something similar to:
Code:
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim nCol As Integer
nCol = MSHFlexGrid1.ColSel
If nCol = 4 Then
set MSHFlexGrid1.CellPicture = picClickedImage.Picture
End If
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim nCol As Integer
If nCol = 4 Then
Set MSHFlexGrid1.CellPicture = picUnclickedImage.Picture
End If
End Sub
Thanks again. :)
Re: VB6 - Can you make MSHFlexGrid cell have a click effect
this maybe easier using a resource file, with some tweaking you also use gifs and jpg
Code:
Private Sub Form_Load()
With MSHFlexGrid1
.Rows = 7
.Cols = 5
End With
End Sub
Private Sub MSHFlexGrid1_Click()
With MSHFlexGrid1
Select Case .Row
Case 2
.Col = 2
Set .CellPicture = LoadResPicture(101, vbResBitmap)
.CellPictureAlignment = flexAlignCenterCenter
Case 3
.Col = 2
Set .CellPicture = LoadResPicture(102, vbResBitmap)
.CellPictureAlignment = flexAlignCenterCenter
End Select
End With
End Sub