How to retrieve combobox selection in a windows form
Posted
by Edward Leno
on Stack Overflow
See other posts from Stack Overflow
or by Edward Leno
Published on 2009-09-24T22:33:38Z
Indexed on
2010/05/04
1:28 UTC
Read the original article
Hit count: 377
All,
I have a simple windows form with a combobox and a 'OK' button. After clicking the 'OK' button, I want to retrieve the selected combobox value.
The GetUserForm has 2 controls: combobox named cmbUser, with a list of 2 values button named btnOK
Nothing has been done to the GetUserForm class itself. The class contains:
public partial class GetUserForm : Form
{
public STAMP_GetUser()
{
InitializeComponent();
}
}
GetUserForm f = new GetUserForm();
f.ShowDialog();
// not sure how to access the combobox selected value?
Do I need to initialize something in the class? Or can I access the controls on the form using the 'f' variable above?
© Stack Overflow or respective owner