[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Combo box problem in Windows application

Posted on 2014-08-09
1
Medium Priority
?
163 Views
Last Modified: 2014-08-09
Hi,
Can u please give example for below scenario
IN c# Windows application

when combo box  value is selected, dynamically label and text box should be created in the panel for entering the values from users prospective.
0
Comment
Question by:mannevenu26
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40251172
One approach:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (comboBox1.SelectedIndex < 0)
    {
        return;
    }

    this.panel1.Controls.Clear();

    switch (comboBox1.SelectedIndex)
    {
        case 0:
            Label lbl1 = new Label() { Text = "A Label", Location = new Point(0, 0) };
            TextBox txt1 = new TextBox() { Text = "A TextBox", Location = new Point(0, lbl1.Bottom + 5) };

            this.panel1.Controls.Add(lbl1);
            this.panel1.Controls.Add(txt1);
            break;
        case 1:
            Label lbl2 = new Label() { Text = "Another Label", Location = new Point(0, 0) };
            TextBox txt2 = new TextBox() { Text = "Another TextBox", Location = new Point(0, lbl2.Bottom + 5) };

            this.panel1.Controls.Add(lbl2);
            this.panel1.Controls.Add(txt2);
            break;
    }
}

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month19 days, left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question