| | |
combobox with mutiple columns
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 3
Reputation:
Solved Threads: 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));
}
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));
}
![]() |
Other Threads in the C# Forum
- Previous Thread: how to display XML file in textBox or Treeview using C#
- Next Thread: countdown timer: time limit from database
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagridview dataset datetime degrees development draganddrop drawing encryption enum excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





