0

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));
}

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by htmlforums
0

Why dont you try DataGridView control instead Combobox with columns?

Actually i am using windows c#. Anyone can help?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.