Click here to Skip to main content
15,920,687 members
Home / Discussions / C#
   

C#

 
AnswerRe: Change the properties of the controls Pin
kadaoui el mehdi27-Oct-10 4:16
kadaoui el mehdi27-Oct-10 4:16 
AnswerRe: Change the properties of the controls Pin
OriginalGriff27-Oct-10 4:19
mveOriginalGriff27-Oct-10 4:19 
AnswerRe: Change the properties of the controls Pin
Luc Pattyn27-Oct-10 4:34
sitebuilderLuc Pattyn27-Oct-10 4:34 
GeneralRe: Change the properties of the controls Pin
OriginalGriff27-Oct-10 4:53
mveOriginalGriff27-Oct-10 4:53 
GeneralRe: Change the properties of the controls Pin
Luc Pattyn27-Oct-10 4:58
sitebuilderLuc Pattyn27-Oct-10 4:58 
GeneralMessage Removed Pin
27-Oct-10 7:38
flflshop27-Oct-10 7:38 
GeneralRe: Change the properties of the controls Pin
OriginalGriff27-Oct-10 8:37
mveOriginalGriff27-Oct-10 8:37 
GeneralRe: Change the properties of the controls Pin
thomforum27-Oct-10 7:51
thomforum27-Oct-10 7:51 
Dear All --

Go through the code below. Pour in your valuable suggestions.

1 combobox, name cbMain and having 1,2,3,4 as values
4 Textboxes txt1, txt2, txt3, txt4

//**************************************************************
try
{
if (cbMain.SelectedItem.ToString() == "1")
{
txt2.Hide();
txt3.Hide();
txt4.Hide();
}
else if (cbMain.SelectedItem.ToString() == "2")
{
txt2.Show();
txt3.Hide();
txt4.Hide();
}
else if (cbMain.SelectedItem.ToString() == "3")
{
txt2.Show();
txt3.Show();
txt4.Hide();
}
else if (cbMain.SelectedItem.ToString() == "4")
{
txt2.Show();
txt3.Show();
txt4.Show();
}

//I want a simpler piece of code fetching similar results
//The selected item in combobox should be passed as an
//argument and appended with the textboxes which are
//to be hidden or shown, say for ex, the below code:

int n = Int32.Parse(cbMain.SelectedItem.ToString());
for (int i = 1; i <= n; i++)
{
//("txt" + i).Show();
//What line will make the trick
}
for (int i = n+1; i <= cbMain.Items.Count; i++)
{
//("txt" + i).Hide();
//What line will make the trick
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

cheers
GeneralRe: Change the properties of the controls Pin
OriginalGriff27-Oct-10 8:14
mveOriginalGriff27-Oct-10 8:14 
GeneralRe: Change the properties of the controls Pin
Luc Pattyn27-Oct-10 9:14
sitebuilderLuc Pattyn27-Oct-10 9:14 
GeneralRe: Change the properties of the controls Pin
thomforum27-Oct-10 14:50
thomforum27-Oct-10 14:50 
GeneralRe: Change the properties of the controls Pin
Luc Pattyn27-Oct-10 15:14
sitebuilderLuc Pattyn27-Oct-10 15:14 
GeneralRe: Change the properties of the controls Pin
thomforum27-Oct-10 18:59
thomforum27-Oct-10 18:59 
QuestionCDOEXM.dll problem when using from Visual Studio 2005/.NET Framework 2.0 Pin
SomsubhroChat27-Oct-10 3:57
SomsubhroChat27-Oct-10 3:57 
AnswerRe: CDOEXM.dll problem when using from Visual Studio 2005/.NET Framework 2.0 Pin
_Erik_27-Oct-10 4:26
_Erik_27-Oct-10 4:26 
GeneralRe: CDOEXM.dll problem when using from Visual Studio 2005/.NET Framework 2.0 Pin
SomsubhroChat27-Oct-10 7:01
SomsubhroChat27-Oct-10 7:01 
GeneralRe: CDOEXM.dll problem when using from Visual Studio 2005/.NET Framework 2.0 Pin
_Erik_28-Oct-10 5:05
_Erik_28-Oct-10 5:05 
QuestionCalling DISKPart commands Pin
avi_dadi200227-Oct-10 1:47
avi_dadi200227-Oct-10 1:47 
AnswerRe: Calling DISKPart commands Pin
_Erik_27-Oct-10 1:58
_Erik_27-Oct-10 1:58 
QuestionTool for real time grapg plotting... Pin
jainiraj27-Oct-10 1:20
jainiraj27-Oct-10 1:20 
AnswerRe: Tool for real time grapg plotting... Pin
Henry Minute27-Oct-10 1:30
Henry Minute27-Oct-10 1:30 
GeneralRe: Tool for real time grapg plotting... Pin
jainiraj27-Oct-10 4:19
jainiraj27-Oct-10 4:19 
GeneralMessage Removed Pin
27-Oct-10 7:39
flflshop27-Oct-10 7:39 
GeneralRe: Tool for real time grapg plotting... Pin
Henry Minute27-Oct-10 7:41
Henry Minute27-Oct-10 7:41 
GeneralRe: Tool for real time grapg plotting... Pin
Dave Kreskowiak27-Oct-10 7:49
mveDave Kreskowiak27-Oct-10 7:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.