Wednesday, January 21, 2009

Own sorting in Infragistics' ultraGrid

My application's user submitted request to add possibility to change way how decimal columns are sorted in grid.

He wanted sort decimals by absolute values.

Turned out it is pretty easy to implement using IComparer interface + grid SortComparer property.

Final effect:

Example code:


Labels:

How to set programically Infragistics ultraGrid headers groups

Infragistics ultragrid is very flexible control.

One of nice option is header groups and levels which is not very common knowledge.

Grouped columns look like this:

 


To archieve that the easiest way is use built-in grid's designer.

But if you want to do the same in runtime (set groups programically) you can look at below code snippet:



Labels:

Friday, January 16, 2009

Problem with running application deployed by Publish option in vs2008

We have recently moved our project to CLR 3.5.

Migration went smoothly but discoverd problem with deployment.

We are using "Publish" option in VS2008 (ClickOnce) .
Project published and installed well but application wont start after...

After hours of fight I've noticed deletion installation folder helped.

So I've prepared script making all job for us:




Labels:

Wednesday, January 14, 2009

Brute force to terminate application

Everybody knows about:

Application.Exit();


But if you looking for brute way to close your app immediately you could use:

System.Environment.Exit(0);

Labels:

Thursday, January 8, 2009

Freezing / refreshing problem

Very often happend your form is not refreshing correctly or freezing.
Another time during processing one task you wanted perform another.

Common knowledge is start using (multi) Threading future in C#

In some (simple) scenarios you can take into consideartion another command:

Application.DoEvents()


Microsoft explains it as:

"When you run a Windows Form, it creates the new form, which then waits for events to handle. Each time the form handles an event, it processes all the code associated with that event. All other events wait in the queue. While your code handles the event, your application does not respond. For example, the window does not repaint if another window is dragged on top. 

If you call DoEvents in your code, your application can handle the other events. For example, if you have a form that adds data to a ListBox and add DoEvents to your code, your form repaints when another window is dragged over it. If you remove DoEvents from your code, your form will not repaint until the click event handler of the button is finished executing. For more information on messaging, see User Input in Windows Forms."

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx


Labels: