Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2007, 11:45 AM
Authorized User
 
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default combobox validation

i am having a combobox . i need the user to select something before he can save or do any other operations.

i searched the net i didn't get good examples...

could anyone please help me out in this....
 
Old June 14th, 2007, 01:23 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi

u just do the following in the save button click event

  if(combobox.text != "")
 {
   //code for saving informations
}
else
{
messagebox("Please select an item in combo");
}

 
Old June 14th, 2007, 09:53 AM
Authorized User
 
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default


thank you for your suggestion.

I am planning to keep my save button disables until the selections are made.

So i would like to know which event "SelectedValueChanged" or "TextChanged" would be appropriate for this...

"SelectedIndexChanged" is used to display the values in other combobox as per selection in the first....

thanks
AKSSMV




Quote:
quote:Originally posted by velan
 hi

u just do the following in the save button click event

if(combobox.text != "")
{
//code for saving informations
}
else
{
messagebox("Please select an item in combo");
}

 
Old June 14th, 2007, 11:17 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

if u use any of the event, after u just click on the combobox the button will get enabled. so textchanged event will be better.

 u check in the save button itself before data get into the database



 
Old June 28th, 2007, 04:07 PM
Authorized User
 
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks

i found it ,it's better to do it in Validating event and check the selected item is null.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Validation using Validation Framework kalyangvd Struts 1 January 2nd, 2008 06:53 AM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM
Combobox stepdev Excel VBA 1 May 22nd, 2006 02:50 PM
combobox Warbird General .NET 0 January 7th, 2005 12:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.