VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,419 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,507 people online right now. Registration is fast and FREE... Join Now!




DataGridView context menu sort

 

DataGridView context menu sort, I need some help with this method.

jase81

1 Jul, 2009 - 06:04 PM
Post #1

D.I.C Head
**

Joined: 2 Mar, 2009
Posts: 57



Thanked: 1 times
My Contributions
The user right clicks in the grid and then selects an option from the context menu. If they choose "sort" it will sort the column which they clicked. This method works but it's slow. If anyone has a better method please let me know.

Cheers

CODE

    Dim hitColumn As DataGridViewColumn

    Private Sub SortToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortToolStripMenuItem.Click
        dataGrid.Sort(hitColumn, System.ComponentModel.ListSortDirection.Ascending)
    End Sub


    Private Sub dataGrid_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dataGrid.MouseUp
        Dim hit As DataGridView.HitTestInfo = dataGrid.HitTest(e.X, e.Y)
        If e.Button = Windows.Forms.MouseButtons.Right Then
            If hit.Type = DataGridViewHitTestType.Cell Then
                hitColumn = dataGrid.Columns(hit.ColumnIndex)
            End If
        End If
    End Sub



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 11:56PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month