Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Using a loop to display additional info. when clicking on an Item in a listbox?

$
0
0
I have a listbox called "lstProducts". When a specific product is "clicked", a description of that specific product is supposed to show up in the textbox "txtDescription" next to the listbox in the GUI. My question is how can I can include a specific description in a textbox called "txtProductDetails" when I click on a specific product in the listbox called "lstProducts"? Should I just use a command button called "Description" and include the switch statement? I am supposed to use loops for my assignment since they are easier than a long IF statement. Here is my code so far:

private void btnDescription_Click(object sender, EventArgs e)

{

   string product;

    if (lstProducts.SelectedIndex != -1)

{

     product = lstProducts.SelectedItem.ToString();

     switch (product)

     {

            case "Microsoft Surface":
                       txtProductDetails.Text = "Screen Size: 10.6'' Storage Capacity: 128 GB";
                       break;


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>