|
-
Feb 15th, 2006, 03:34 AM
#1
Thread Starter
Fanatic Member
Accessing an event of another form
I have 2 forms...imagine form A and form B...
I would like to access Form B's paint event from Form A ..
and I would like to set e.graphics.fillrectangle(example,something) of the other form.
Can someone advice me about that?
Thanks
Godwin
Help someone else with what someone helped you! 
-
Feb 15th, 2006, 03:38 AM
#2
Re: Accessing an event of another form
You can check out this link to see if it helps
http://www.devcity.net/Articles/94/1/multipleforms.aspx
I think part 3 refers to accessing events or subs on other forms...
(this link has been getting good use lately)
Last edited by gigemboy; Feb 15th, 2006 at 03:41 AM.
-
Feb 15th, 2006, 03:39 AM
#3
Re: Accessing an event of another form
Declare a variable of type FormB as WithEvents in FormA. You can then handle its events just like you would any control or component that you added in the designer. Alternatively you can use the AddHandler statement. A form is an object just like any other, and you can handle its events like you would any other. We're used to handling a form's events inside the form itself but that's not necessary. It is important to remember that each form you design is just a class like any other, and each instance you create is just an object like any other. Form's are not really any different to anything else you work with in .NET.
-
Feb 15th, 2006, 03:43 AM
#4
Re: Accessing an event of another form
I saw your post before you edited it, which proves that you only just beat me, and yet I must still slink away, defeated... 
 Originally Posted by gigemboy
-
Feb 15th, 2006, 03:47 AM
#5
Re: Accessing an event of another form
lol darn dialup... i cant edit as quick as I need to
-
Feb 15th, 2006, 04:09 AM
#6
Thread Starter
Fanatic Member
Re: Accessing an event of another form
Hi Jm,
Im actually trying to use a function and do this..
VB Code:
ublic Function changecolor()
For Each child As Form In parent.MdiChildren
Dim g As Graphics = child.CreateGraphics()
Dim rec As New Rectangle(0, 0, child.Width, child.Height)
Dim lbr As New LinearGradientBrush(rec, Color.DarkOrange, Color.CadetBlue, LinearGradientMode.Vertical)
g.FillRectangle(lbr, rec)
child.Hide()
Next child
End Function
but It does what it has to just for a second...I think the logic is wrong...Im not sure how to do that permenant change on the paint event
Godwin
Help someone else with what someone helped you! 
-
Feb 15th, 2006, 04:10 AM
#7
Thread Starter
Fanatic Member
Re: Accessing an event of another form
Thanks for the competition,Im also learning faster and getting to finish my work faster
Godwin
Help someone else with what someone helped you! 
-
Feb 15th, 2006, 04:15 AM
#8
Re: Accessing an event of another form
You can create a Paint event handler in your parent form and then use AddHandler to link it to the Paint event of each child. That handler can then do the drawing. I haven't tested that but I believe the thoery is sound.
-
Feb 15th, 2006, 04:21 AM
#9
Thread Starter
Fanatic Member
Re: Accessing an event of another form
yep.Ill do that..Ill look up how to do that and go ahead
Godwin
Help someone else with what someone helped you! 
-
Feb 15th, 2006, 06:56 AM
#10
Thread Starter
Fanatic Member
Re: Accessing an event of another form
ahh,I seriously cant get this to work...Im struggling for hours..I could only find ways to add addhandler everywhere...
I want to use a forloop and control all the paintevents in the childform...I dont know how to do it,please help me
Godwin
Help someone else with what someone helped you! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|