Click Event Problem
-
Hello, I'm writing a program which draws charts and I'm followong this article: http://www.codeproject.com/csharp/zedgraph.asp[^] Here is my source code: http://paste.plone.org/12853[^] The problem is that when I click the Add Chart button nothing happens(as you could see on the picture http://img54.imageshack.us/img54/3590/addgk9.jpg[^] althought I call the createGraph function on this event. But when I click on the button and then on the graph itself like you could see on the picture it draws me(when I click just on the graph without the button nothing happens) http://img238.imageshack.us/img238/7291/firstrd8.jpg[^] I want that when I click on the "Add Chart" button it will draw me the chart. Why do this problem happens? I gave you the sorce code on the top if you need it. Thanks a lot and I hope I was pretty obvious.
SnaidiS(Semion)
-
Hello, I'm writing a program which draws charts and I'm followong this article: http://www.codeproject.com/csharp/zedgraph.asp[^] Here is my source code: http://paste.plone.org/12853[^] The problem is that when I click the Add Chart button nothing happens(as you could see on the picture http://img54.imageshack.us/img54/3590/addgk9.jpg[^] althought I call the createGraph function on this event. But when I click on the button and then on the graph itself like you could see on the picture it draws me(when I click just on the graph without the button nothing happens) http://img238.imageshack.us/img238/7291/firstrd8.jpg[^] I want that when I click on the "Add Chart" button it will draw me the chart. Why do this problem happens? I gave you the sorce code on the top if you need it. Thanks a lot and I hope I was pretty obvious.
SnaidiS(Semion)
I can think of one thing right away that you should check. i assume that this button you want to click, that isn't doing anything even though you have an action written for it, is not "wired" to the event. Here, select the button in the gui designer and go to its properties. then click the little lightning bolt in the propertygrid and goto its events... Now... if you see an empty box to the right of the "Click" event... then my guess is right and the event is not wired. Click inside that empty box, and a combobox-dropdown button should appear...hit it and, select "button1_Click" from the list. now it should work sometimes this happens when you paste stuff from other forms or something...
-
I can think of one thing right away that you should check. i assume that this button you want to click, that isn't doing anything even though you have an action written for it, is not "wired" to the event. Here, select the button in the gui designer and go to its properties. then click the little lightning bolt in the propertygrid and goto its events... Now... if you see an empty box to the right of the "Click" event... then my guess is right and the event is not wired. Click inside that empty box, and a combobox-dropdown button should appear...hit it and, select "button1_Click" from the list. now it should work sometimes this happens when you paste stuff from other forms or something...
-
hmm...then it's probably a logic bug in your code or that control or somewhere between. did you try setting a breakpoint and stepping into it? I'm not sure if you know this or not. you click in the margin to the left of this line "private void button1_Click(" and get a little red circle to appear...the breakpoint... then do debug -> start. and when you click the button, the code should run to that line.. then do debug -> "step into" and line after line see what gets executed and what doesn't. if you cant figure it out...you can send me you test project and i can try to find the problem. i know you posted the code, but i'm a bit lazy to recreate your project...and maybe theirs something not in the code thats messing it up :P
-
hmm...then it's probably a logic bug in your code or that control or somewhere between. did you try setting a breakpoint and stepping into it? I'm not sure if you know this or not. you click in the margin to the left of this line "private void button1_Click(" and get a little red circle to appear...the breakpoint... then do debug -> start. and when you click the button, the code should run to that line.. then do debug -> "step into" and line after line see what gets executed and what doesn't. if you cant figure it out...you can send me you test project and i can try to find the problem. i know you posted the code, but i'm a bit lazy to recreate your project...and maybe theirs something not in the code thats messing it up :P
:) I tried to debug it and when I click the button it makes the function but I dont see the results on screan.. OK, I'll upload the project. Here is the project. http://fileho.com/download/e95cc0167872/Graphics.rar.html[^] and listen If you have problem with the Graph Control so the dll is on the folder. Thanks :)
SnaidiS(Semion)
-
:) I tried to debug it and when I click the button it makes the function but I dont see the results on screan.. OK, I'll upload the project. Here is the project. http://fileho.com/download/e95cc0167872/Graphics.rar.html[^] and listen If you have problem with the Graph Control so the dll is on the folder. Thanks :)
SnaidiS(Semion)
my email is the username i use here @gmail... :P
-
my email is the username i use here @gmail... :P
-
I uploaded it http://fileho.com/download/e95cc0167872/Graphics.rar.html[^]
SnaidiS(Semion)
ok i figured it out :P zgc.Invalidate(); add that to the end of your createGraph function. it tells that control that it needs to be invalidated cause its data was changed. its really the control makers fault here... they should of done that automatically when the data is changed :P if you ever get problems... zgc.Refresh(); this can do it and force the repaint to happen right away, but i think it might be slower... its better with invalidate :P their are other things like zgc.SuspendLayout() make lots of changes to the control zgc.ResumeLayout() if you encounter lots of flickering or whatnot ... these functions exist in all controls that inherit system.control or system.usercontrol fyi ...like if you ever get this problem in the future :P i was tipped off to the problem when while stepping through with the debugger that i saw the button working properly... and it was because the whole form was getting invalidated cause of the debugger kept on moving ontop of the window with each refresh..or something...
-
ok i figured it out :P zgc.Invalidate(); add that to the end of your createGraph function. it tells that control that it needs to be invalidated cause its data was changed. its really the control makers fault here... they should of done that automatically when the data is changed :P if you ever get problems... zgc.Refresh(); this can do it and force the repaint to happen right away, but i think it might be slower... its better with invalidate :P their are other things like zgc.SuspendLayout() make lots of changes to the control zgc.ResumeLayout() if you encounter lots of flickering or whatnot ... these functions exist in all controls that inherit system.control or system.usercontrol fyi ...like if you ever get this problem in the future :P i was tipped off to the problem when while stepping through with the debugger that i saw the button working properly... and it was because the whole form was getting invalidated cause of the debugger kept on moving ontop of the window with each refresh..or something...
-
Thanks! It works now, you are great! May the world be full with people like you :) Thanks !
SnaidiS(Semion)
Glad it worked :-D