Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 7th, 2007, 10:18 AM   #1
Rythn
Newbie
 
Join Date: Nov 2007
Posts: 2
Rep Power: 0 Rythn is on a distinguished road
Accesing Control Properties on Another Form

I'm trying to enable a button on the main form, once the child form is closing. I'm using a MDI here, and I noticed that if I do this by a button click on the child form it works. But it aint happening if i use the FormClosing or FormClosed events.

Please Help

Private Sub frmSuppliers_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Dim frmMain As New frmMain
frmMain.tsbSuppliers.Enabled = True
End Sub
Rythn is offline   Reply With Quote
Old Nov 7th, 2007, 10:41 AM   #2
Alias
Newbie
 
Join Date: Oct 2007
Posts: 29
Rep Power: 0 Alias is on a distinguished road
Re: Accesing Control Properties on Another Form

Does an instance of the main form not already exist? is that not where the child forms are hosted?

Creating a new instance of the main form and setting the enabled state of the button of that instance will not have an effect on the form already shown.

Try looking into the forms 'Parent' property and take it from there.
Alias is offline   Reply With Quote
Old Nov 7th, 2007, 11:51 AM   #3
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,010
Rep Power: 5 lectricpharaoh will become famous soon enough
Re: Accesing Control Properties on Another Form

your best bet here is probably to create a public property on the child form that is set according to user input into the child form. Then, after you close the child form, you can check this property from the main form.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Nov 7th, 2007, 2:44 PM   #4
Alias
Newbie
 
Join Date: Oct 2007
Posts: 29
Rep Power: 0 Alias is on a distinguished road
Re: Accesing Control Properties on Another Form

How would it be best to declare, reference and use new variables for this task when it could be done with a simple cast?

Imagine...

VB.NET Syntax (Toggle Plain Text)
  1. ((Button)Parent.Controls["ButtonName"]).Enabled = value
Alias is offline   Reply With Quote
Old Nov 7th, 2007, 9:54 PM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,010
Rep Power: 5 lectricpharaoh will become famous soon enough
Re: Accesing Control Properties on Another Form

Quote:
Originally Posted by Alias
How would it be best to declare, reference and use new variables for this task when it could be done with a simple cast?
I was suggesting that for encapsulation. Having the child form muck with the parent form's controls abrogates the parent form's responsibility to take care of its own controls. Having a mechanism (property or otherwise) as part of the child form's interface that allows the parent form to determine its state and act appropriately seems a better solution to me.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Jan 9th, 2008, 12:50 PM   #6
SydneyMcConnell
18 Year Old Programmer
 
Join Date: Jan 2008
Posts: 26
Rep Power: 0 SydneyMcConnell is on a distinguished road
Re: Accesing Control Properties on Another Form

Should be something along the lines of:

Me.Parent.Controls("tsbSuppliers").enabled = false

Give that a try.
If it doesn't work there, try it in the child form's Disposing event.
SydneyMcConnell is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show or hiding forms/modifying control properties ..from different a form.. cloud- C# 4 Nov 10th, 2006 10:51 AM
.NET Timer Form closing issue MBirchmeier C# 4 Nov 21st, 2005 10:00 AM
entering data into excel from a form glevine Perl 1 Nov 18th, 2005 5:03 PM
Button to a form JaDa64 Visual Basic .NET 17 Jul 3rd, 2005 3:27 PM
Sending a web form as parameter see07 C# 4 Mar 24th, 2005 9:25 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC