|
C#
if(MessageBox.Show("abc", "def", System.Windows.Forms.MessageBoxButtons.OKCancel) == DialogResult.OK)
{
}
else
{
}
All the best,
Martin
|
|
|
|
|
The message box returns a DialogResult object (example result). by having condition like this
<br />
result.toString() == "Yes"<br />
result.toString() == "Ok"<br />
result.toString() == "Cancel"<br />
.....<br />
....<br />
..<br />
.<br />
this will let you know what button is clicked
|
|
|
|
|
Why should somebody compare the string instead of the enum value itselve?
|
|
|
|
|
why are you confused Martin
Because it is the same. No errors will happen and the same result will get back
|
|
|
|
|
If you write everything correct, but if not compiler will not tell you.
But again, why?
All the best,
MArtin
|
|
|
|
|
ok man i already said down that i was wrong and you were right
anyway thanks for the new info.
take care
|
|
|
|
|
(Next time it's your turn again)
All the best,
Martin
|
|
|
|
|
it's not the same..
comparing strings takes more resources than comparing integers (which enums are)..
life is study!!!
|
|
|
|
|
quiteSmart wrote: result.toString() == "Yes"
result.toString() == "Ok"
result.toString() == "Cancel"
You should compare the result directly with the members of the DialogResult enumeration, because it's less error-prone.
result == DialogResult.Yes
result == DialogResult.OK
result == DialogResult.Cancel
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
IT is the same man
no errors will happen
|
|
|
|
|
quiteSmart wrote: IT is the same man
no errors will happen
Sure, it will work, but what if Microsoft decides to change the return values of toString in the next framework version. Comparison with the enumeration members will still work, but your string comparison will not.
Furthermore, I wasn't refering to errors at runtime, but mainly to those made during development. If you have a typo in a string value, the code will compile fine, but it will not do what you expect it to do. If you have a typo in the identfiers of enumeration members, the compiler will complain, so the process of writing the code is less error-prone.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
It seems that you convinced me. I guess your totaly right. I will start using the enumeration from now on.
Thanks anyway
|
|
|
|
|
Stefan Troschütz wrote: Sure, it will work, but what if Microsoft decides to change the return values of toString in the next framework version. Comparison with the enumeration members will still work, but your string comparison will not.
Not just then, but what about foreign language OSes. Wouldn't they have localized button names?
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
But if you have a typo somewhere in your string the compiler won't tell you about it which he would do when using enumeration values.
Robert
|
|
|
|
|
Can I change the color of perticular cell in C# for DataGrid control.
I want to change the color of the cells which have numeric value below 100.
|
|
|
|
|
foreach (GridViewRow row in GridView1.Rows)
{
long cellValue = long.Parse(row.Cells[1].Text.ToString());
if (cellValue > 100)
{
row.Cells[1].BackColor = System.Drawing.Color.Red;
row.Cells[1].ForeColor = System.Drawing.Color.Blue;
}
}
Here Cells[1] 1 should be the index of the Column that you want to compare.
for(int i=0;i<500;i++)
Console.WriteLine("I Love C# \n");
|
|
|
|
|
But I am not using any WEB page , can I use (GridViewRow control ) for the desktop application aswell.
|
|
|
|
|
I want to learn how to create custom skinned GUIs like the ones we see
when using products like StyleXP or WindowBlinds.
I've just started with basic windows forms programming, and I'm finding
the default styles to be sucky.
What are the techniques of 'skinning' a window's form? (In Visual C++ 6
and in Visual C#) Will it vary depending on languages? as in VC++6 and
VC#?
A detailed explanation would be very helpful.
Thanks.
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
A good place to start could possibly be to create a UserControl , override the OnPaint method and spam some GDI+
|
|
|
|
|
Can you create a Usercontrol in .Net compiled as ocx?
I would need to add it to VC6.0 resources.
(it takes me less time to make the usercontrol in .Net then making an ocx in C++ )
thanks
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
I am a noob. But as far as I know the final output from .NET is Assembly, Merge Module (.exe, .dll, .module)
Activex have versioning problem thats why the concept of Assembly comes into view .
Am I right Geeks?
|
|
|
|
|
Lol, many thanks for the reply, I did some searching on the net.
The only thing I came up with where people in forums arguing whether or not it was possible, but I didn't find any actual answers.
I think it must be possible, but up until now, I haven't found an answer .
It is to no avail anyway, I made a quick ocx in VB6 and it doesn't get fired in the dialog anyway. (the ocx's sole purpose was to call an exe).
|
|
|
|
|
Hi,
I'm creating a tool, in which i have to pass data from one project (B)
to other project (A).
But i dont want the A's object to be created in B..
How can i achieve this..
Can i add one more project C.. that only listen and stores.
C is accessible to B to write the data.
And can be extracted whenever necessary to the A.
Please help me..
Note: A & B are separate projects.
Regards,
nas
|
|
|
|
|
Actually yesterday there was a thread that talk about the same issue.
i will give you the reference to it,
the link is this
|
|
|
|
|
Try using IPC messenger or remoting.
Or you can have an xml file and implement a file system watcher on it.
When ever you try to write into the file , file changed event can be fired and fetch your data from the xml file.
|
|
|
|