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
Printable View
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
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)
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.
I saw your post before you edited it, which proves that you only just beat me, and yet I must still slink away, defeated... :cry:Quote:
Originally Posted by gigemboy
lol darn dialup... i cant edit as quick as I need to :D
Hi Jm,
Im actually trying to use a function and do this..
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 :(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
Thanks for the competition,Im also learning faster and getting to finish my work faster :)
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.
yep.Ill do that..Ill look up how to do that and go ahead :)
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