Results 1 to 5 of 5

Thread: [RESOLVED] VB6 - Can you make MSHFlexGrid cell have a click effect

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    50

    Resolved [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

  2. #2
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    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.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    50

    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.

  5. #5
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width