combobox with mutiple columns

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 3
Reputation: htmlforums is an unknown quantity at this point 
Solved Threads: 0
htmlforums htmlforums is offline Offline
Newbie Poster

combobox with mutiple columns

 
0
  #1
Aug 12th, 2008
Hi,
I having problem with c# combo box control with multiple columns.
I have one combox with 2 columns:

code(char 5) desc(char10)

d1 day1
d10 day10


I using Add items to add in those code and desc, but the column position is out. I was thinking of taking the 5 minus the length of the code, say x = 5 - code.length(), and then put it as space(x), how can i add spaces string in c#? and how to get the CODE only as selected display value instead of code+desc ?

Is there any simple way to do it? Below is the code
Thank you!!


private void Form1_Load(object sender, System.EventArgs e)
{
string col1;
string col2;
int s;
string space;
for (int i=0;i<2;i++)
{
if (i==0)
{
col1="d1";
col2="day1";
}
else
{
col1="d10";
col2="day10";
}

s=5-col1.ToString ().Length ();
space=new String ("",s);
comboBox1.Items .Add (col1+space+col2);
}
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//MessageBox.Show (comboBox1.Text.Substring (0,5));
}
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 513
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 89
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: combobox with mutiple columns

 
0
  #2
Aug 13th, 2008
Why dont you try DataGridView control instead Combobox with columns?
KSG
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 3
Reputation: htmlforums is an unknown quantity at this point 
Solved Threads: 0
htmlforums htmlforums is offline Offline
Newbie Poster

Re: combobox with mutiple columns

 
0
  #3
Aug 13th, 2008
Originally Posted by selvaganapathy View Post
Why dont you try DataGridView control instead Combobox with columns?

Actually i am using windows c#. Anyone can help?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC