Click here to Skip to main content
12,951,034 members (58,599 online)
Rate this:
 
Please Sign up or sign in to 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.

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 16-Sep-12 7:58am
Updated 16-Sep-12 8:42am
v4

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.

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 :-)
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,084
CHill60 3,480
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,830


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 16 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100