Solved

Combo Box Selected Value

Posted on 2013-05-31
1
464 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
Graphics 2 32
HttpPostedFile 1 30
Release Dynamically Allocated Memory in C# 3 38
I need help with Crystal Report's Parameter Prompt Form 2 51
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

837 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