• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

Why is the selectedtext in the combobox aligned the to the right where every other item is aligned to the left.

Following is a code snippet

cboSystemStatus.DataSource = objRPlayer.GetSystemStatusDescriptions();   // <- Datatable prepopulated from stored procedure
cboSystemStatus.ValueMember = "systemStatusID".ToString().Trim();
cboSystemStatus.DisplayMember = "SystemStatusDescription".ToString().Trim();
//cboSystemStatus.SelectedValue = objRPlayer.SystemStatusID;

Now every thing appears perfectly when i drop down my combobox.   All Display members appear perfectly.   No problem there....

When i select an item in the combobox.  The selected displaymember appears to be cut off by the first few characters.  As if the trim function is not being preformed correctly and being aligned from the right hand side.

I'm a bit of a newbie with windows forms.  Can somebody tell my why only the selected text is out of place?????

Thanks in Advance

1 Solution
Hi camdempster,

cboSystemStatus.DisplayMember = "SystemStatusDescription".ToString().Trim();
this line isn't trim because "SystemStatusDescription".ToString().Trim() = "SystemStatusDescription".

Don't trim your field name :) Please trim values of records in your table.

see this sample:

tableset ts = objRPlayer.GetSystemStatusDescriptions();

for (int i=0;i<ts.rows.count;i++)
     ts.rows[i]["SystemStatusDescription"] = ts.rows[i]["SystemStatusDescription"].tostring().trim();

Good luck,
camdempsterAuthor Commented:
Bang on VINHNL,

Thanks dude, worked perfectly.  Is there not an easier way of doing it though?  I just thought I could trim the column rather than traverse through and trim each cell?

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now