|
|
What is it that you are using the ToolStrip's click event for?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
Do you have any idea on how to attache image/docs/pdf saved from SQL DB then send it to email?
All the attachements of diff. docs are all saved in our SQL DB, they want me to send the attched files as per record at attachment to email.
PLSzzz.
Dabsukol
|
|
|
|
|
Have a look at this[^]
The example is in VB.Net but I hope you can easily convert it to C#.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
form name is "Test".
i want to close this form using short cut Alt+F4
cany anyone help me
|
|
|
|
|
Normally this should work by default...
|
|
|
|
|
Just press Alt+F4 in your keyboard. The form will be closed automatically.
You don't need to write some codes for that.
|
|
|
|
|
It should just work as others have said. If for some reason it doesn't, you can code it yourself. This is a little function I use occaisionally to do the opposite - stop Alt+F4 closing the form. Adapt it to suit.
private const int WM_SYSKEYDOWN = 0x0104;
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
return ((msg.Msg == WM_SYSKEYDOWN) && (keyData == (Keys.Alt | Keys.F4)));
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
try
{
int i = 1;
int j = 2;
return i;
}
finally
{
i += 3;
}
The code in the finally statement will be executed ? when? before return or after return ?
|
|
|
|
|
What happened when you tried?
|
|
|
|
|
Well, that's a dumb question. If there's no other code, then before or after the return are basically the same thing, excepting that when the code returns, i will no longer exist. In fact, I don't think this will compile, because the scope of i is the try block, I think you need to define it outside the try for the catch to see it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Well that is a dumb answer because it's totally unhelpful!
You're right that it won't compile, but surely you can see that the question works by simply declaring i at the method level instead. And there is in fact a subtle effect of the try-finally.
int foo()
{
int i = 1;
try { return i; }
finally { i = 5; }
}
This code compiles, but what does foo() return? I think quite a lot of people would expect it to return 5, since the finally block is executed before the method returns. But the return value is *evaluated* before the finally block runs and the method returns 1.
Now what would happen if we boxed the int in a class of our own?
class BoxedInt { public int Value; }
BoxedInt bar()
{
BoxedInt i = new BoxedInt() { Value = 1 };
try { return i; }
finally { i.Value = 5; }
}
While foo() returns 1, bar() returns a BoxedInt whose Value is 5. That's because BoxedInt is a class and thus a reference type, so it does not matter if the return value is evaluated before or after the finally block executes. Change BoxedInt to a struct, and bar will return a BoxedInt with Value equal to 1 as well.
I'd say there's some subtlety here, so calling that a stupid question seems to me rather a stretch.
|
|
|
|
|
So... you did try it, but asked the question anyway? 
|
|
|
|
|
Now that got me nicely confused.
You replied to my message so presumably "you" means me. But what "it" and "the question" refers to is less clear. I tried many things including compiling and running the various code snippets I've put up on this thread. I may have asked questions too, but I am not the OP so if you were referring to the original message that might explain the confusion.
If you did mean I tried something (and consequently found out what it does) and still asked what it does, let me know what it was and I will attempt to communicate whatever it was I was wondering about more clearly.

|
|
|
|
|
Whoops, I meant to reply to the OP.
|
|
|
|
|
I think it was an interesting question... thou I don't see why you need to ask when you can just try yourself. Thou as Christian said, you variable in the finally block is not in scope.
The answer would appear that the finally code is executed after the return thou I would say that the function is not complete until after the finally block. That means whenever return is called then that is the value that will be return regardless of what is done in the finally block.
I wonder what would happen if you put a return in the finally block too....
...oh, you cant return from a finally block.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
The answer is in fact more subtle: The finally block executes before the method returns, but the return value is *evaluated* before the finally block runs. Because his code works with a value type (int) the increment he did in the finally is not reflected in the return value of the method - it's as if the compiler transformed return i; to int ret = i; i += 3; return ret; , executing the finally block after evaluating the return expression, but before returning. If it had been an object (reference type) and the finally modified the state of that object, the caller would "see" the changes made by the finally block. See my replies above if you want more details.
|
|
|
|
|
That's the same thing I said just using different words, so maybe before correcting me you should have spent time understanding what I said and not just repeating me and thinking that you have given a different answer.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I'll try to remember you're an ungrateful little brat. Actually you didn't say half of what I did, although you did say something vaguely similar. (Don't reply just to repeat a claim - readers can just look at the thread and decide for themselves.)
|
|
|
|
|
You know, going round insulting the regulars isn't a good way to endear yourself to a community.
|
|
|
|
|
And you think I deserved the snotty reply he gave me? I think I contributed a very clear explanation of what exactly happens and provided more information than he had done (his explanation was onto something, but didn't point out how reference versus value types would affect the outcome - so I had something to add).
It's up to you whether you rate contributions according to how regularly the author posts messages. I'd rather rate them for quality and value. And I reserve the right to return rudeness to anyone, regular or not.
|
|
|
|
|
Ungrateful for what? you didn't post anything that was designed to help me.
I said that the return is executed before the 'finally code' but the function is not complete (returned) until the finally code is processed.
dojohansen wrote: Actually you didn't say half of what I did
I was not trying to claim to have said what you did - I said you said what I said.
Anyway, my point is I don't appreciate something thinking there correcting me by basically saying the same thing.
If I said: "1 + 1 = 2"
and then someone said: "No, Actually, one add one equals 2"
then that person would be considered some sort of idiot, don't you think?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Just for any who are interested then dojohansen sent me an email with the following content...
Hi,
I don't want the thread to degenerate into a petty fight between you and me about whether or not we contributed something. But I do want to replay to *you* - hence this private message.
musefan wrote:Ungrateful for what? you didn't post anything that was designed to help me.
I said that the return is executed before the 'finally code' but the function is not complete (returned) until the finally code is processed.
I definitely said something that was meant to help, although it was not meant for you specifically. A reply in a forum is a reply to a message, not to the author of the message - if I wanted to address you I'd send a private message like this one.
What you said (as you accurately repeat in the above quote) is not wrong, but nor is it very precise. There's no mention of the crucial fact that the return value is evaluated before the finally executes[I said that the 'finally block' executes after the return - which to me is the same as saying "the return value is evaluated before the finally executes"]. There is also nothing that can help your reader understand that it would make a difference if the method worked with a reference type rather than a value type[personally I see the OP as simply asking if finally code is executed before or after the return statement. Not "how do I add to a variable before returning the value?"].
So although I feel people ought to be very happy to be corrected, and I try to be so myself when I am, this message was not even an attempt to correct you. I merely tried to clarify further and add some information regarding the subtleties that arise from the fact that the return value is evaluated before the finally block runs and returned afterwards.
To this, you gave a reply that was less than useless. Having first misinterpreted my message as a correction you decided to give me a snotty reply accusing me of trying to score brownie points by repeating you[I did not accuse you of 'stealing' my answer]. Frankly I feel that if you thought that was what I was doing you should be kind enough to the rest of the community to either just forget about it, or alternatively bring it up in a private message. [the impression I got (intended or not) was that you were correcting me and then saying it was the same answer - to me that warrants a telling off]
musefan wrote:Anyway, my point is I don't appreciate something thinking there correcting me by basically saying the same thing.
You appear very insecure to be so touchy about what you perceive as being corrected[insecurity is irrelevant here and therefore I can only assume it is meant as a dig]. Perhaps you should consider, if someone does some day write the same thing as you, the possibility that what you said wasn't very clear, or not complete, or that maybe the person had misunderstood your message. Immediately going for the knee-jerk reaction and attacking people for "copying" you makes you look fairly stupid, especially if the people you accuse of doing so are making contributions of superior quality to your own.[yeah maybe I could have handled it differently but you clearly misunderstood my answer and therefore instead of 'correcting' it then you should say you don't understand]
All of this having been said, I hope we can both contribute constructively to the forums and the community and not have to waste time on silly ego-driven [I am on an internet forum that does not display my real name - my ego is not effected either way by any post from anyone] activities that just pollute the threads for anyone interested in the *issue* we're supposed to discuss[people don't have to read what they don't think is worth reading].
Have a nice day,
Dag Johansen
...I don't have a problem being corrected when I am wrong (I am also a user of this forum to learn in addition to help) But there are some comments in this email that I don't see to make sense (which lead me to believe my original 'answer' requires more intelligence to interpret than I had hoped) but maybe that's just my opinion. everyone else if welcome to form there own. My comments on the email are in square brackets [ ] BTW
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
He's obviously a self riteous idiot who likes the sound of his own voice (or rather the look of his own typing). Ive not even seen the name here before today, but in the last few hours he's answering question after question in the most verbose way possible.. often replying to other satisfactory answers (like yours above) just to add his 2pence worth.
Ignore him. You do a great job of answering questions here.
|
|
|
|
|
Thanks for your appreciation - I will take your advise and ignore any more responses
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|