|
I store them as int , and the reconstitute them with a favorite little function of mine that verifies that the int value is valid inside the enum.
does not exist in the enumeration definition</param>
public static T IntToEnum<T>(int value, T defaultValue)
{
T enumValue = (Enum.IsDefined(typeof(T), value)) ? (T)(object)value : defaultValue;
return enumValue;
}
In the examples posted by another user, ordinals of 1, 2, and 4 were used. If you called my function with an invalid value, it would gracefully recover by returning the specified default enum value. So...
ChangeOptions changeOption = IntToEnum(5, ChangeOptions.Orientation)
...would result in changeOption being set to ChangeOptions.Orientation (because 5 is an invalid ordinal), while doing this...
ChangeOptions changeOption = IntToEnum(2, ChangeOptions.Orientation)
...would result in changeOption being set to ChangeOptions.Size (because 2 is a valid ordinal).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Good Morning,
I'm searching for info how to Print out the info from the datagridview
This is a little urgent
Regards
Arnold
|
|
|
|
|
Atis wrote: I'm searching for info how to Print out the info from the datagridview
Good luck. Do you know where to search?[^]
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Atis wrote: This is a little urgent
So what?
Atis wrote: I'm searching for info how to Print out the info from the datagridview
Have a look at this[^]. Though this is for DataGrid, but DataGridView should also behave same.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I'm building a game in C# and i need your help in something...
It's a simple game, no graphics, just text background and voice.
the game itself is built on choices,I mean that every now and than in the game the player has to chose between a couple of choices.
so I'm putting 4 buttons and i want that every time the player has to chose, he'll be able to press the button the text will change and so on.
so here my questions:
how can i make it that every time there is a choice it will change accordingly and the button won't be tied to one line?
thanks a lot!!!
|
|
|
|
|
DanteV92 wrote: how can i make it that every time there is a choice it will change accordingly and the button won't be tied to one line?
|
|
|
|
|
sorry...
I meant that how can i make the Text change accordingly to the choice by one of the buttons?
|
|
|
|
|
You write code code in the Click event handler of the buttons...
|
|
|
|
|
C# controls have a "Text" attribute. Assigning a string to this attribute will change the control's text. For example:
System.Windows.Forms.TextBox nextQuestion;
...
nextQuestion.Text = "What was the name of Paul McCartney's first band?"; or
System.Windows.Forms.Button nextAnswerButton;
...
nextAnswerButton.Text = "The Beatles";
|
|
|
|
|
so if my buttons name is "button1" so it will go something like this?
System.Windows.Forms.TextBox button1;
...
button1.Text = "What was the name of Paul McCartney's first band?";
|
|
|
|
|
|
but the question is how will the program know to which text to go?
i mean do i have to declare something or something like that or any other action?
thanks a lot!!!
|
|
|
|
|
Whatever string you assign to the text member will appear on the screen. It's your decision.
|
|
|
|
|
can you show me how i assign a string to a text please and in what section of the code i write it in?
thanks!!!!!!
|
|
|
|
|
You need to learn how to program in C#. There are many tutorials on the Web. They're free.
|
|
|
|
|
You need to dynamically create your choices based on the allowed choices. You can still use the same event listener if you utilize the Tag property in windows forms based applications, or in web forms based applications you will be able to use the ClientID property.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
what do you mean by "dynamically create your choices"?
|
|
|
|
|
It is possible to develop your user interface at run time without the benefit of using the Visual Designer. By doing so you will have complete control over the look, placement, actions, etc. of these buttons. Creating controls at runtime is called dynamic creation. There are many articles available that can shed a lot more detailed light on the subject than I can in a brief post.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
can please refer me to an article that can explain to me?
thanks!!!
|
|
|
|
|
Now, I'm use to data paging in DataGridView. When I search data on DataGridView that is just show data in present page. Have the way solve this problem? I would like get all data rows of DataTable that is being data paging on DataGridView.
For example: pagesize = 5, DataTable have two pages.
data in 1st page:
name age
John 21
N.John 20
Nancy 20
Tomath 21
Jan 22
and data in 2nd page:
name age
Jany 20
Alpha 21
Don 22
Bony 20
Tomy 22
One-page is present page. I'm beginning search data at "name" column as 'Tom'. It is just show one row in DataGridView. This data is correct when it show two rows in DataGridView. That is all. Can anyone help me?
modified on Wednesday, September 10, 2008 7:04 PM
|
|
|
|
|
Hi everybody.
How can I Abort all created Thread ?
For example :
I created a button that creates a thread by clicking on it.
Now I want close all of open Threads when my WinForm close.
|
|
|
|
|
When you create the threads, set the IsBackground property to true .
Then these threads are terminated when the app closes.
----------------------------------
Be excellent to each other
|
|
|
|
|
The threads belong to the process they were created from and cannot exist outside it. When the process is terminated, all it's threads are too.
|
|
|
|
|
I like to create member variables for the the class that contains the run method in my thread and then have a thread-safe method in said class that allows graceful termination of the run method.
If I have a form that closes I create an listener on the OnClosing event and then signal, or request from the threads to stop gracefully.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
HI
I'm using SetupApi dll and invoking SetupDiGetClassDevs Method to list all the devices of my computer, but i need to know the devices that are connected to the Serial port or the ports that contain the device and it name, it will help a lot for..
please do help me asap.
modified on Wednesday, September 10, 2008 7:18 AM
|
|
|
|