|
|
Hi!
I want to execute some code when I click a picturebox, but I don't know how, and I can't find an answer anywhere. So could some kind person out there take some time to teach me?
Thx Dan
|
|
|
|
|
Handle the click event of the picture box
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
DanSteeve wrote: I want to execute some code when I click a picturebox, but I don't know how, and I can't find an answer anywhere. So could some kind person out there take some time to teach me?
You can just handle the Click event by creating an event handler that does whatever you want it to do.
example:
myPictureBox.Click += new PictureBox.Click(myFunctionToDoSomething);<br />
<br />
<br />
private void myFunctionToDoSomething(object sender, EventArgs e)<br />
{<br />
}<br />
Seems like that would do the trick.
I'm assuming the code you want to execute is part of your application, of course. You could fire off another process within the event handler, if you wanted.
Hope that helps!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
To all,
i have a c# application that have one textbox only..
i want to drag a doc file to that textbox..at the moment i drag that file ,
the address/path of that file should appear on that textbox...
pls help
Munish rathore
|
|
|
|
|
|
Look at the AllowDrop property for the TextBox class. It's pretty self explanatory.
|
|
|
|
|
I tried to compile source c# files from inside code as follows:
...
string[] filesArray;//array of c# files full path
CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("c#");
CompilerParameters parameters;
...
CompilerResults results = codeProvider.CompileAssemblyFromFile(parameters, filesArray);
Compiler reported error: Line number 0, Error Number: CS2032, 'Character '\v ' is not allowed on the command-line or in response files;
I have red that c# compiler doesn't accept characters from 0 to 31 in ascii table plus '|' character.
I didn't manage to remove those characters from source files.
What should i do?
Mile
|
|
|
|
|
Hello,
I have two servers at different locations and I want to match the timestamps generated by one server.
I have an Idea of generating timestamp for GMT 0, this means that timestap will be same across all servers. How can I generate this timestamp? any idea?
Pavas
|
|
|
|
|
DateTime.ToUniversalTime()
only two letters away from being an asset
|
|
|
|
|
I guess it will work...
Thanks a lot
Pavas
|
|
|
|
|
hi guys,
I have this sql query:
string commandtext = "select Res_nr from AfwTarieven where Res_nr='"+resid+"'";
now i want that if he find a Res_nr that is equal to resid, do something:
{}
bud if there is no Res_nr that is equal to my resid, then do somthing else.
How can i write that in code? i had something like this , bud i got a error:
mycomm = new SqlCommand(commandtext, myconn);
int a = Convert.ToInt32(mycomm.ExecuteScalar());
if(a.ToString() == null)
{
MessageBox.Show("no Res id found");
}
else{
MessageBox.Show(a.ToString());
}
can someboddy help me ? thanx
|
|
|
|
|
Why didn't you post the error message, don't you think that would be the quickest way to fix the problem?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
I have a couple of thoughts here - the first being that you shouldn't use commandtext here. Use a Stored Procedure so that you don't end up opening your app up to s SQL Injection attack. Secondly, if you are going to return a Scalar, use
SELECT (COUNT(1)) FROM AfwTarieven WHERE Res_nr = @Res_Nr in your stored procedure. If it returns 0, then it isn't present - anything else and it is.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete Oihanlon,
Thank u , great help
|
|
|
|
|
You're welcome.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
my program is working fine everywhere except one vista home premium client pc.
there it shows "NullReferenceException : object reference not set to ..................."
if any one can give some clue where could be the problem or any information if required from me?
the relevant code is below:
cLock = new ClsHasp();
bLock = cLock.gfCheckLock();
cLock is class variable of my FrmMain and is an object of class ClsHasp, and contains a function public bool gfCheckLock(), bLock is obviously bool type.
error is in second line only 1 of several client pcs.
thanking you in anticipation.
manoj sharma
09313603665
manoj.great@yahoo.com
|
|
|
|
|
Check the method gfCheckLock() there might be a variable/object in there that gives the error.
Or it might just be in the constructor of the ClsHasp if there are objects/variables creates/initialized in there.
good luck.
V.
If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)
|
|
|
|
|
class ClsHasp
{
private int seed; private int lptNum; private int passw1; private int passw2;
public ClsHasp()
{
seed = 0; lptNum = 0; passw1 = 0; passw2 = 0;
}
public bool gfCheckLock()
{
try
{
System.Windows.Forms.MessageBox.Show("1");
===============
i m trying above in gfCheckLock(), even before any statement i m displaying a message, then also the same exception??
any ideas??
manoj sharma
09313603665
manoj.great@yahoo.com
|
|
|
|
|
Could be, not so long ago I had the same problem and tried to debug with messageboxes, they never showed either, but still the code was further down the line, so yes.
Comment out all lines in gfCheckLock and do a return true .
V.
No hurries, no worries
|
|
|
|
|
thanx.
i tried the same. this time its working(how?) but need to do the stuff inside.
manoj sharma
09313603665
manoj.great@yahoo.com
|
|
|
|
|
So check the code that you replaced, the bug is in there somewhere.
|
|
|
|
|
as u can see above very first line of message doesn't get displayed. so what could b wrong?
manoj sharma
09313603665
manoj.great@yahoo.com
|
|
|
|
|
How the hell should I know?
Somewhere in the code you just replaced some variable or object hasn't been initialized...
If you want help, please be more specific, I can't tell what you're doing if you don't elaborate on it more. I didn't develop that piece of code you know. I suggest you try to do some debugging or something.
|
|
|
|
|
please dont don't get it wrong? code is not giving problem everywhere?? it is running fine everywhere else.
but on 1 pc only this is the error. so i guess it's not related to code but something other than that. that's why i need experts viewes.
to start debugging on that client machine (i cant use debugger as no source code is there no vs2k5 is there) i m creating exe here, sending it client and then i came to know the results. that's why i m giving message. return true suggested by you works, but instead first line of messagebox doesn't come up only that single machine.
hope this cools you down. any ideas??
manoj sharma
09313603665
manoj.great@yahoo.com
|
|
|
|