CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Posts
    55

    Disabling Flexgrid Header click...

    How do I disable clicking on the header in a MSFlexGrid ?

    I tried:

    If fg1.row = 0 then Exit Sub

    in the click event, which does nothing, it's like clicking the firrst row of data.

    and I tried:

    If fg1.row = 1 then Exit Sub

    in the click event, which disables the header row and the first row of data.

    Thanks
    Rel
    Last edited by Relentless; May 16th, 2005 at 11:45 PM.

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Disabling Flexgrid Header click...

    'a trick could be:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Dim CounterCol As Long
    With grdFlex
       .GridLines = .GridLinesFixed
       .Rows = 10
       .Cols = 10
       .FixedRows = 0
       .Row = 0
       For CounterCol = 0 To .Cols - 1
          .Col = CounterCol
       
       
          .CellBackColor = &H8000000F
          
          
       Next
       .Col = 0
       .Row = 0
    End With
    End Sub
    Else you will have to use Api to get mouse and decide if click happened on
    header of grid...
    for example, see:
    http://www.codeguru.com/forum/showth...d+column+width
    Last edited by Cimperiali; May 17th, 2005 at 07:53 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Dec 2002
    Posts
    55

    Re: Disabling Flexgrid Header click...

    Thanks for the cool code, Cimperiali, it will come in handy.

    This did the trick:

    If fg1.MouseRow = 0 Then Exit Sub

    Thanks
    Rel

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Disabling Flexgrid Header click...

    Never looked at that prop. Thanks for pointing me there!

    ---------------------------------------------------------------------------
    From msdn
    Code:
    MouseCol, MouseRow Properties
    Returns the current mouse position, in row and column 
    coordinates.
    
    Syntax
    object.MouseCol [=value]
    object.MouseRow [=value]
    
    Syntax for the MouseCol and MouseRow properties has these parts:
    Part       Description 
    object    An object expression that evaluates to an object in the Applies To list. 
    value     The row and column coordinates that specify the current mouse position. 
    
    Remarks
    Use these properties programmatically to determine the mouse location. 
    These properties are useful in displaying context-sensitive help for individual 
    cells and testing whether the user has clicked on a fixed row or column.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured