Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello Friends,

I was just working with VB today yet it isn't my field of interest but I was trying to create a custom theme for windows form application, I started by creating a WPF based custom control (Seriously I haven't worked with it ever), I created a TitleBar with it, with a Title text on top and three buttons on the right hand corner as usual, now I was writing the event methods, and I want a way such that when I click one of the buttons in this custom control, I can access it's parent form properties or method. For Example, If I click on the leftmost button, The form closes, and if I click the first button, the form minimizes irrespective of the form name, so that whichever form uses it, can use it's feautres. I was trying to figure out how can it be done.

Please help me figure out this.

I know this is not the correct syntax but it is what I am trying to implement.

VB
Public Sub btnClose_MouseUp(sender As System.Object, e As System.EventArgs) Handles btnClose.MouseUp

Parent.CloseForm()

End Sub


This is not at all correct but I write it just like this because I wanted to explain the question as it may not be clear by my words.

Please help me regarding this....

Thank you.
Posted
Updated 16-Sep-12 8:42am
v4

1 solution

I Friends,
I have successfully solved it just by getting my hands dirty with .Net syntax. Actually, I do not work with .Net and I am not even a Computer Programmer, So, when I stuck at a point, without thinking for a while i just posted this question, but after that I kept on trying, and here's the result. I wasn't that difficult.

Here is my so simple solution to it, please tell me about the correctness of this code.

VB
Public Sub btnClose_MouseUp(sender As Object, e As EventArgs) Handles btnClose.MouseUp

   Form.ActiveForm.Parent.Close()

End Sub


I am not hundred percent sure that it is correct, but as per now, it's working successfully.
Thank you for your time.

Regards
Tushar Srivastava :-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900