Click here to Skip to main content
Rate this: bad
good
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 8:58am
Edited 16-Sep-12 9: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 Smile | :)
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 605
1 Maciej Los 319
2 BillWoodruff 184
3 Richard MacCutchan 180
4 Suraj Sahoo | Coding Passion 180
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 16 Sep 2012
Copyright © CodeProject, 1999-2014
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