|
BTW, I placed my cursor on the 'TreeNodeMouseClickEventArgs' argument in VS 2012 and pressed F1 for the MSDN help on what that 'e' represents and it mentioned nothing about it. What is that called anyway?
|
|
|
|
|
Please start posting these kinds of questions in Q&A, clearly tagging them to indicate if they are WinForms, WPF, or whatever.
My sense is you are not spending enough time really studying how to use .NET controls, and you are asking for "more help than you really need," far too frequently.
Do you have a good book on basic WinForms programming with example code for you to study, and use ?
imho, there's no substitute for hands-on careful study, on your own, with the WinForms Controls: most of them are really kind of "fossils" from the old days of COM and ActiveX, dressed-up for the .NET party, and each of them has their own "quirks."
The Visual Studio IDE and Property Browser are great tools for studying what the defaults of Control Properties are, and what Properties, and Events, and settings, are available. Experiment !
imho, you also need to spend a little time studying the CodeProject guidelines, and how CP works.
I, and others will, I'm sure, be happy to assist you to "walk forwards along" the path towards mastery of WinForms, but I, and most likely others, will not "carry you;" if we did, you would not really learn.
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
I'll post in the Q&A as you suggest. I'm a bit older and the C# and .net coding is harder for me to grasp. I do spend a lot of time googling for answers but often the code I find I just don't understand it.
For example, I do see that Sender arg a lot and try to use it like Sender.Checked on a node checkbox but that doesn't work. I also see the e args and try using e.Checked and that doesn't work. sometimes the this. member works ok and other times not.
Seems to me if your coding in C# that the C# group would be where one should post vs the Q&A but I'm sure you have a reason for asking me to not post here in C#.
|
|
|
|
|
Hi RFresh,
It's not my intention to be critical, or patronizing, but I do think that if you are at the point where you don't have a clear grasp of the fundamentals of what a WinForms EventHandler, and its sender/EventArgs parameters, are, you may be studying "hard," but not "smart."
I strongly suggest you start off by using a resource like this free book, "Dot Net Book Zero," by Charles Petzold [^], and bear down it. Or, Jesse Liberty's over-view books on C# are excellent (O'Reilly).
If you are coming from a deep-background in COM, ActiveX, C/C++, to WinForms, then I'd recommend Chris Sell's book on Windows Forms (Addison-Wesley); disclaimer: I was a paid technical editorial assistant on that book.
Just to be clear, my opinion that the type of specific questions you are asking on this Forum (now) are best served in Q&A, are just my opinion, and I do not represent, or speak for, CP in any way.
The general idea is that forums like this one are meant to be for discussion of broader issues in using C# ... but that's my interpretation.
good luck, Bill (who started programming after age forty)
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
Bill,
Thanks for the pointers...I will get Charles' book.
|
|
|
|
|
I added the 'Menu' item to VS 2012 Express (using C#) toolbox but its disabled. At work I'm using VS 2012 Premium and added the Menu item to the toolbox and it did not disable it and thus I could make use of it.
Anyone know why the Express version might be disabling the Menu component on the toolbox menu?
Thanks...
|
|
|
|
|
I'm trying to save one of my settings.settings fields when I close my VS 2012 C# app but I'm getting an error saying this is a read-only property. Where so I change it to read/write?
Thanks...
private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.emailAddress = "someone@isp.com";
}
|
|
|
|
|
If your setting is a User Setting, you need to save all the current User Settings to make them persist between Application use; if your Setting is an Application Level Setting, you cannot change it at run-time. In the Visual Studio Settings Designer you can change the scope of a Setting to 'User.
Properties.Settings.Default.Save(); Quote: Settings that are application-scoped are read-only, and can only be changed at design time or by altering the .config file in between application sessions. Settings that are user-scoped, however, can be written at run time just as you would change any property value. The new value persists for the duration of the application session. You can persist the changes to the settings between application sessions by calling the Save method. [^] I found the information here useful: [^].
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
Ahhhh...yes, the difference (for me) was that I had some items set to Application and thus they were read-only. I changed them to User and can now save their data.
Thanks Bill.
|
|
|
|
|
Bill, this is the oddest site to find things, you mention before to delete a message and repost it but there was no way to delete. Now you're suggesting I vote a thank you which I 100% agree with but I don't see anything regarding voting. Strangest site!
|
|
|
|
|
There are little red (down vote) and green (up vote) arrows to the left of the message you want to vote on. Just open the message and move your mouse towards the left side under the document icon and it'll show the voting arrows.
At the bottom of your messages are the links to edit/delete, etc. You can use those too.
|
|
|
|
|
Yep, I went to look again and finally figured that out!!! Up vote to you Bill...!!
|
|
|
|
|
rfresh wrote: Up vote to you Bill.. But you still have not upvoted his message.
Use the best guess
|
|
|
|
|
I dont have a habit of using try-cahtch block unless i am sure it throws an exception... is it advisable to use it in most places of your code.... what is the best practice?
Srinivas K
|
|
|
|
|
Srinivas Kalabarigi wrote: what is the best practice? To only catch what you can handle. If you can't handle it, don't catch it. If it doesn't throw exceptions, don't try.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You mean to say its not good practice to catch all....?
Unless necessary... right
Srinivas K
|
|
|
|
|
Srinivas Kalabarigi wrote: You mean to say its not good practice to catch all....? It's a known anti-pattern; catching all is the worst practice, a remnant of the "On Error Resume Next" lazyness.
Catching an unexpected exception might lead to unexpected behaviour (since your app is in an unknown state), data-loss, and generally makes it harder to solve bugs.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Catching an unexpected exception might lead to unexpected behaviour... (
Except of course that in servers
1. Not catching it means it is lost.
2. Most of the time, most errors are non-disruptive. For example null pointer errors, and in a correctly designed layered system such errors, although unexpected, will not stop the application.
|
|
|
|
|
It is a good practice to catch exceptions; but if someone is sure about some exception then it is better to work on your code so that it doesn't throw any exception; let's say if divide by zero throws an exception then you shouldn't allow your code to reach to that point so that division by zero may occur. In that case it is not recommended to use the try-catch block but it is recommended to not let your code reach to that point so that that exception may occur.
|
|
|
|
|
I dont pay much attention to practices when it comes to exceptions.. I guess it depends on what you are coding...
However, I have coded both pro app and pro web sites..
And I must say....
The best use of catch exception code for me has always been...
If Website, catch just about all exceptions and store them into a database for review and easy lookup for when users report bugs and problems that may be very hard to reproduce on your own..
In applications, catch exception and present user with interface to report exception to staff..
That has been the extend of my exception code...
=)
|
|
|
|
|
Forbiddenx wrote: catch just about all exceptions Not using a try-catch construction; there's an event that's raised for unhandled exceptions; that's the place where one would log them.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, I know what your talking about..
But I typical do this.. where i want to log data because it gives me more control.
And sometimes depending on what the exception is and where it happened, i don't log it...
So, if i did it in the exception event.. it would have less control.
But I do see what your saying.. and its also a method that works.
Try
{
some code
}
catch (Exception exc)
{
log it, or present it to the user exc...
}
=)
|
|
|
|
|
Forbiddenx wrote: where i want to log data because it gives me more control. And sometimes depending on what the exception is and where it happened, i don't log it... How do you have "more" control?
I do hope that you catch specific exceptions, and aren't advocating a pokemon-handler? Swallowing exceptions is a worst-practice:
catch (Exception exc)
{
log it, or present it to the user exc...
}
And how is it preferable to have your code littered with repeating code, consisting of merely a try-and-log? Simply log from the one place where all unhandled exceptions end up, and be done with it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I think we are misunderstanding each other.
I do use specific exceptions but at times I also use the generic all exceptions..
But, I also bomb out if I use the generic all exception and stop everything in its tracks.
catch (Exception exc)
{
log it, or present it to the user exc...
BOMB OUT.... alert.. done.
I never resume operation that would be bad!
}
I only resume operation if I
catch (ExceptionTYPE exc)
{
try to recover..
}
Yes, it does add some extra code, but it is better then resuming you want to log any exception that occurs globally.
=)
|
|
|
|
|
Forbiddenx wrote: But, I also bomb out if I use the generic all exception and stop everything in its tracks. There's the problem; handling a "specific" exception means that you cannot use the generic exception to handle it - it'd be passing in other exceptions that weren't meant to be handled that way. Nice example is a Sql Server that's offline, and a client-app that keeps whining about a password being incorrect (since that was all that's handled locally).
Hence, the best practice would be to catch and handle what you expect, and to log everything else on a higher level.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|