We help IT Professionals succeed at work.

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

camdempster
camdempster asked
on
Medium Priority
265 Views
Last Modified: 2010-04-16
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



Comment
Watch Question

Commented:
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,
VINHNL

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.