|
|
 |
| C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
|
 |

November 16th, 2009, 06:34 AM
|
|
Registered User
|
|
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to refire selectedindex event of combobox in c#
Hello all
i am developing a window application using vs2008
at this moment i want to re-fire selected index event of a combo box upon hitting a button.
the combo box belongs to dropdownlist type.
what is appropriate way to do this ?
thanks
|

November 16th, 2009, 06:39 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,453
Thanks: 0
Thanked 50 Times in 50 Posts
|
|
The easiest way is to simply refactor your code so the OnSelectedIndexChanged event calls a method, and then call the method in the Button OnClick event as well.
Alternatively you can call an event method exactly like any other method:
Code:
Combo1_SelectedIndexChanged(null, EventArgs.Empty);
__________________
/- Sam Judson : Wrox Technical Editor -/
|

November 16th, 2009, 10:21 AM
|
|
Registered User
|
|
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hmmm thanks for your reply but this is not what i was looking for.
in fact, upon hitting a button i want to reload combo box as it was on form load & as i had said earlier this belongs to drop down list (not drop down) so i couldn't apply combo1.text="";
i want to set combo to its default selected item (that is blue bar).
i am sorry if i gave wrong information earlier :(
|

November 16th, 2009, 10:29 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,453
Thanks: 0
Thanked 50 Times in 50 Posts
|
|
Well a DropDownList must always have an item selected, so you just need to set the SelectedIndex to whichever item is the 'default' - e.g. the first one:
DropdownList1.SelectedIndex = 0;
__________________
/- Sam Judson : Wrox Technical Editor -/
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |