Results 1 to 10 of 10

Thread: MouseDown handled clause.

  1. #1

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    MouseDown handled clause.

    Is there any way to imitate the e.Handled clause for a KeyPress event in a MouseDown event?
    "I'm Brian and so is my Wife"

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: MouseDown handled clause.

    Yes

    Exit Sub

    would have the same effect as

    E.Handled = True
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    Re: MouseDown handled clause.

    HiTaxes,

    Thanks for your reply.
    EXIT SUB may well be the way to go, but this is the problem I am having.

    I have a datagrid which is sorted on a hidden column called GRADE_HIDDEN.
    Now, when a user clicks on the GRADE column header to sort the datagrid, instead of sorting on GRADE, I want it to be sorted on GRADE_HIDDEN.

    This is what I have so far in the MouseDown event of my DataGrid.
    VB Code:
    1. Dim myGrid As DataGrid = CType(sender, DataGrid)
    2.         Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
    3.         Dim view As DataView
    4.  
    5.  
    6.         'this retrieves the location in the grid that the user clicked using the mouseeventargs for the coordinates
    7.         hti = myGrid.HitTest(e.X, e.Y)
    8.  
    9.         Select Case hti.Type 'evaluate the type of hit test info
    10.             Case DataGrid.HitTestType.ColumnHeader 'look for the column header
    11.                 If hti.Column = 5 Then 'the column property indicates the index of the column clicked
    12.                     view = New DataView(ds.Tables("INCIDENT"), "", "GRADE_HIDDEN", DataViewRowState.CurrentRows)
    13.                     IncidentList.DataSource = view
    14.                     Exit Sub
    15.                 End If
    16.  
    17.         End Select

    Now, if I debug this at the Exit Sub line, the grid is indeed sorted on GRADE_HIDDEN.

    However, after the Exit Sub, the Sort completes somehow and the grid is re-sorted on the GRADE column.

    I suppose what I am asking is "How to re-direct a Datagrid sort to a column other than the one that has been clicked on?"
    "I'm Brian and so is my Wife"

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: MouseDown handled clause.

    Hi,

    Then there must be something in your subsequent code which affects it.

    Put your breakpoint on the Exit Sub and then use the stepover key (F10) to see where it goes. e.g. is there a click or mouseup event in action?

    If that fails use DataGrid.Update before the Exit Sub.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    Re: MouseDown handled clause.

    Thanks for your Reply.

    I've done as you suggest.

    However, the code exits after the Exit Sub and doesn't go elsewhere and no other part of my code is called with relation to the DataGrid.
    "I'm Brian and so is my Wife"

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: MouseDown handled clause.

    Hi,
    I think you need to rebind the control immediately before the Exit Sub
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  7. #7

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    Re: MouseDown handled clause.

    Hi Taxes,

    Thought I was doing that already, no?
    IncidentList is the name of my DataGrid control.
    "I'm Brian and so is my Wife"

  8. #8
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: MouseDown handled clause.

    Hi,

    I'll experiment with it later if no one else has an answer.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  9. #9

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    Re: MouseDown handled clause.

    I'd appreciate any more input you may have Taxes. Many thanks.
    "I'm Brian and so is my Wife"

  10. #10
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: MouseDown handled clause.

    Hi,

    I think you deed to add the line

    IncidentList.DataBind() after

    IncidentList.DataSource = view


    But I also wonder why you have:

    IncidentList instead of MyGrid (Although they are interchangable)
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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