Solved

Combo Box Selected Value

Posted on 2013-05-31
1
466 Views
Last Modified: 2013-05-31
Hi,

I have a class file where am passing controls from a form in loop

foreach (Control frmControl in frm.Controls)
if (ReferenceEquals(frmgbxcontrol.GetType(), typeof (ComboBox)))

Open in new window


I need to read the selectedvalue of combo box here. What do I do ?
0
Comment
Question by:GRChandrashekar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39210433
Cast. I suggest using the as operator (http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.71).aspx) instead.

foreach (Control frmControl in frm.Controls)
{
    ComboBox cb = frmgbxcontrol as ComboBox;

    if (cb != null)
    {
        MessageBox.Show(cb.SelectedValue.ToString());
    }
}

Open in new window

0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 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