Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Combo Box Selected Value

Posted on 2013-05-31
1
Medium Priority
?
473 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

609 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