ComboBox Sorting Defect!

Oops! Never expected this behavior from such a standard control: Winforms ComboBox.

One of the common things our applications require is bind a data source with Collection-base UI elements like ComboBox. The best code any one could write would be: 

cmbTest.DisplayMember = "Name";
cmbTest.ValueMember = "ID";
cmbTest.DataSource = _employeeRecords; 

I would give this a perfect 10!

The combo box displays all the Employee Names in the combo box.  What if you wanted to sort these items?

Let’s use the Sorted property of ComboBox.

this.cmbTest.Sorted = true;

Dush!!!  The code stopped working.

You won’t see Employee Names in the combo box any more. What you would come through is items showing the namespace of the object

_employeeRecords

Now did you expect that?

Continue reading » · Rating: · Written on: 02-24-09 · No Comments »

Exception Message Box in C#

 

Its time to forget the old traditional message box with limited functionalities. buttons, icons, text area and what not! Microsoft has unleashed a new message box – new, yet not so new.

For those who have used SQL Sever 2005 GUI, might have probably noticed a message box that shows additional information, copying the text to clipboard, a checkbox on message box, different set of buttons and many more features.  This message box is now open for reuse in your applications. 

This is not a ‘big-bang’ release made by Microsoft.  It has come out very quietly. Yes the name ‘ExceptionMessageBox’ is confusing – but you can still use it in your applications. This standalone exception dialog box can be used in applications just like any other managed APIs.

Probably, you never know the next version of myTracker may use this message box too :)

Let’s hear it from Microsoft:

The exception message box is a programmatic interface that you can use in your applications for any tasks for which MessageBox may be used. The exception message box is a supported managed assembly designed to elegantly handle managed code exceptions. It provides significantly more control over the messaging experience and gives your users the options to save error message content for later reference and to get help on messages.

Download Link: 

http://download.microsoft.com/download/f/7/4/f74cbdb1-87e2-4794-9186-e3ad6bd54b41/SQLServer2005_EMB.msi 

Continue reading » · Rating: · Written on: 02-24-09 · 1 Comment »