Board index » Visual Studio » datagrid sort cursor

datagrid sort cursor

Visual Studio295
I have a datagridview that allows the user to sort the column by clicking on

the header of the column the user wishes to sort. I did not code this, it

had the ability when the datagrid was populated. My question is how can I

change the cursor to an hourglass when the user clicks the header and change

it back to the default once the sort is accomplished. The database is large

and the sort takes a few seconds. Need something to show the user the

program is working so the user does not continue to click the header.



Thanks,



Thomas



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


-
 

Re:datagrid sort cursor

Hi,



In the mousedown event on the datagrid check and see if the use clicked on

the column header and change the cursor.



Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As

System.EventArgs) Handles DataGrid1.Click



Dim pt As Point = DataGrid1.PointToClient(Cursor.Position)



Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt)



If hti.Type = DataGrid.HitTestType.ColumnHeader Then



' Change cursor here



End If



End Sub



Here is how to know when the grid was sorted. Change the cursor back after

it was sorted.



http://www.windowsformsdatagridhelp.com/default.aspx?ID" rel="nofollow" target="_blank">www.windowsformsdatagridhelp.com/default.aspx=7bd8c12a-b448-4b16-8c80-7a5dcc005f84



Ken

-----------------------------

<thomasp@msala.net>wrote in message

I have a datagridview that allows the user to sort the column by clicking on

the header of the column the user wishes to sort. I did not code this, it

had the ability when the datagrid was populated. My question is how can I

change the cursor to an hourglass when the user clicks the header and change

it back to the default once the sort is accomplished. The database is large

and the sort takes a few seconds. Need something to show the user the

program is working so the user does not continue to click the header.



Thanks,



Thomas



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access





-

Re:datagrid sort cursor



I failed to mention I am using VB2005. I changed your code a little to work

in 05, but I can't find a listchanged event to use to know when to go back

to the default cursor.



Do you have a suggestion for that?



Thanks,



Thomas



Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As

System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown



Dim myHitTest As System.Windows.Forms.DataGridView.HitTestInfo

' Use the DataGrid control's HitTest method with the x and y properties.

myHitTest = DataGridView1.HitTest(e.X, e.Y)



If myHitTest.Type = DataGridViewHitTestType.ColumnHeader Then

Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

End If





End Sub



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

-