Jump to content
  • Advertisement
Sign in to follow this  
Winegums

C# combo box data manipulation

This topic is 4054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've put some combo boxes into my c# application, but could use some pointers on how to use the data they churn out. firstly, if i have a combo box with set selections that are integers, how do i turn the char into an integer? casting doesn't work like it does in c++.. also is there a way to chech data types to prevent bad data? is this usually done by if (object.getType() == int) //it's an int... thanks for your time.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Winegums
firstly, if i have a combo box with set selections that are integers, how do i turn the char into an integer? casting doesn't work like it does in c++..


char? If you want to convert strings to integers use int.Parse or int.TryParse

Quote:
Original post by Winegums
also is there a way to chech data types to prevent bad data? is this usually done by

if (object.getType() == int) //it's an int...


Well you can stop the user from editing the field by setting the boxes DropDownstyle to Forms.ComboBoxstyle.DropDownList, forcing them to select one of the values you put in the list. Otherwise you can check the return value on int.TryParse, which will return false if the string couldn't be converted to an integer.

Share this post


Link to post
Share on other sites
brilliant, thanks. thats exactly what i needed.

one more question...how do i delete stuff in c#? Particularly in linked lists...


EDIT: Something else i've had a problem with is application loops. Is there a way to, for example, constantly update an onscreen counter with the time or whatever?

[Edited by - Winegums on May 14, 2007 12:19:47 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Winegums
one more question...how do i delete stuff in c#? Particularly in linked lists...

LinkedList.Remove().

Quote:
EDIT: Something else i've had a problem with is application loops. Is there a way to, for example, constantly update an onscreen counter with the time or whatever?
There are a number of ways of doing this. The easiest would probably be to drop a Timer onto the form and update the time from its Tick event.

When writing a program that has to update quickly (eg, redrawing the screen in a game) I prefer to use the Application.Idle event.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!