Solved

Combo Box Selected Value

Posted on 2013-05-31
1
461 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
1 Comment
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now