473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Getting the Onsorted event in a datgridview

Hi all,

I am trying to detect when the onsorted event fires in a datagridview.

I want to freeze the screen on ColumnHeaderMouseClick (That's OK) and unfreeze after the sort.

(That's not OK)


CODE:
Expand|Select|Wrap|Line Numbers
  1.     Private Sub dgv_ColumnHeaderMouseClick _ 
  2. (ByVal sender As System.Object, ByVal e As  _ System.Windows.Forms.DataGridViewCellMouseEventArgs) _ 
  3. Handles dgv.ColumnHeaderMouseClick 
  4.  
  5.         LockWindowUpdate(Me.Handle.ToInt32)
  6.  
  7.     End Sub
The code above works fine and to call the onsorted event I am using

CODE:
Expand|Select|Wrap|Line Numbers
  1.    Public Sub dgvLabProcesses_Sorted _ 
  2. (ByVal sender As System.Object, ByVal e As System.EventArgs) _ 
  3.  Handles dgvLabProcesses.Sorted
  4.         LockWindowUpdate(0)
  5.     End Sub
  6.  
Anyone know why this is not happening? Is blocking the screen update preventing sorting?


Many Thanks

SS
Jan 20 '09 #1
4 2195
Plater
7,872 Expert 4TB
I would say that yes LockWindowUpdate() is blocking the updates, as that is what it is designed to do.
If you are just trying to keep people from interacting with the form while the sorting is going on, their are other options you can take.
I throw up a "splash screen" of sorts that says what is going on, and hide it when done with the sorting.
You could also set the Enabled property to false on the form (which would disable it along with the child controls) and then set it to true again.
You could mark all the controls as hidden and then make them visible again when you are done too.

Be aware that not all column types are considered sortable and thus will never fire the Sorted event.
Jan 20 '09 #2
Hi all,

Thanks Plater for clarifying that. rather than use a splash screen I am going to hide and show the datagridview.

Expand|Select|Wrap|Line Numbers
  1.     Private Sub dgv_ColumnHeaderMouseClick _ 
  2. (ByVal sender As System.Object, _ 
  3.  ByVal e As System.Windows.Forms. _ 
  4. DataGridViewCellMouseEventArgs) 
  5.         dgv.Visible = False
  6.         Formatting()
  7.     End Sub
  8.  
And then in the formatting subroutine dgv.visble = true.


thanks all
Jan 20 '09 #3
Frinavale
9,735 Expert Mod 8TB
Just a suggestion:

It's a good idea to at least show a message that you are doing something when you hide the GridView or else your end users will be left wondering what happened to it.

When you hide the GridView, add a label in it's place saying "Sorting...." or something.

This will inform the end user that something is happening so that they aren't worried the application has crashed or is doing something "weird". This is why Plater suggested a splash screen.

-Frinny
Jan 20 '09 #4
Thanks frinavale that is a good idea so I will put a label with 'Loading...' under the dgv.
Jan 20 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Harlin Seritt | last post by:
I have the following script. Two widgets call the same function. How can I tell inside of the called function which button called it?: def say_hello(): print 'hello!' print widget root =...
1
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
5
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
3
by: Sosh | last post by:
Hi, I'm sure there must be any easy way of doing this, but I just can't see it: I have a repeater bound to a dataset. In each item of the repeater I have a listbox with a few options. I...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
5
by: Carlo \(mcp\) | last post by:
Good morning I have this lines: AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler AddHandler MyControl2.Parent.Paint, AddressOf PaintParentHandler AddHandler...
4
by: AshishMishra16 | last post by:
HI friends, I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for...
3
by: wolverine | last post by:
Hi, I am injecting a javascript code into html pages and attaching some dom events to some elements via attachEvent (IE only). I just want to know that is there any chance by which my event...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.