Set selected value...
-
On asking 'how to select value from a combobox based on another combobox selected value', following was replied as one way:
// This code only works if you know how many items are in each collection.
private void m_CmbBox1_SelectedIndexChanged(Object Sender EventArgs e)
{
switch(m_CmbBox1.SelectedIndex)
{
case 0:
m_CmbBox2.SelectedIndex = 0;
break;
case 1:
m_CmbBox2.SelectedIndex = 1;
break;
case 2:
m_CmbBox2.SelectedIndex = 2;
break;
default:
m_CmbBox2.SelectedIndex = m_CmbBox2.Items.Count - 1;
}
}:doh: Got to read a comment on this, to which I fully agree: A bright example of anti-programming!
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
-
On asking 'how to select value from a combobox based on another combobox selected value', following was replied as one way:
// This code only works if you know how many items are in each collection.
private void m_CmbBox1_SelectedIndexChanged(Object Sender EventArgs e)
{
switch(m_CmbBox1.SelectedIndex)
{
case 0:
m_CmbBox2.SelectedIndex = 0;
break;
case 1:
m_CmbBox2.SelectedIndex = 1;
break;
case 2:
m_CmbBox2.SelectedIndex = 2;
break;
default:
m_CmbBox2.SelectedIndex = m_CmbBox2.Items.Count - 1;
}
}:doh: Got to read a comment on this, to which I fully agree: A bright example of anti-programming!
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
I saw that one too, but was too distracted to notice the stupidity in it at the time. +5...
I wasn't, now I am, then I won't be anymore.
-
On asking 'how to select value from a combobox based on another combobox selected value', following was replied as one way:
// This code only works if you know how many items are in each collection.
private void m_CmbBox1_SelectedIndexChanged(Object Sender EventArgs e)
{
switch(m_CmbBox1.SelectedIndex)
{
case 0:
m_CmbBox2.SelectedIndex = 0;
break;
case 1:
m_CmbBox2.SelectedIndex = 1;
break;
case 2:
m_CmbBox2.SelectedIndex = 2;
break;
default:
m_CmbBox2.SelectedIndex = m_CmbBox2.Items.Count - 1;
}
}:doh: Got to read a comment on this, to which I fully agree: A bright example of anti-programming!
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
If you didn't laugh, you'd cry... :sigh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
I saw that one too, but was too distracted to notice the stupidity in it at the time. +5...
I wasn't, now I am, then I won't be anymore.
Okie! I just thought of sharing it here. Who knows someone might be implementing something like this somewhere. ;)
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
-
If you didn't laugh, you'd cry... :sigh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
:-D What did you do?
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
-
:-D What did you do?
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
A bit of both!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
On asking 'how to select value from a combobox based on another combobox selected value', following was replied as one way:
// This code only works if you know how many items are in each collection.
private void m_CmbBox1_SelectedIndexChanged(Object Sender EventArgs e)
{
switch(m_CmbBox1.SelectedIndex)
{
case 0:
m_CmbBox2.SelectedIndex = 0;
break;
case 1:
m_CmbBox2.SelectedIndex = 1;
break;
case 2:
m_CmbBox2.SelectedIndex = 2;
break;
default:
m_CmbBox2.SelectedIndex = m_CmbBox2.Items.Count - 1;
}
}:doh: Got to read a comment on this, to which I fully agree: A bright example of anti-programming!
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
Sandeep Mewara wrote:
default: m_CmbBox2.SelectedIndex = m_CmbBox2.Items.Count - 1;
The items are not in common! But still the other cases can be avoided when the index falls with in the count. Am i making sense?! :confused: ...
Regards Vallarasu S | FSharpMe.blogspot.com
-
Sandeep Mewara wrote:
default: m_CmbBox2.SelectedIndex = m_CmbBox2.Items.Count - 1;
The items are not in common! But still the other cases can be avoided when the index falls with in the count. Am i making sense?! :confused: ...
Regards Vallarasu S | FSharpMe.blogspot.com
Don't ask. I have no idea how this default condition was thought of! :doh:
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]