Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2003, 07:51 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reference to another Windows form Controls

Can anyone please advise how I refer to another forms controls in VB.NET

I have one Parent form and two Child forms I want to set the enable properties to false on the parent form toolbar from the child forms. In VB6 it just used to be parent.tbar.button1.enable = false. Now it’s ?????? FRUSTRAITING!!!


 
Old September 24th, 2003, 11:12 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What I do is create an instance of the other form(s). The startup form or startup method (Sub Main) would normally instantiate 1 or more forms so you can show and hide them. Once you have an object reference to them you can do whatever you want with those forms.

Peter
 
Old October 7th, 2003, 10:58 PM
Registered User
 
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vince,

   I know it's frustrating but here's what I did.

First, I declared public variables to hold references to the toolbars in my parent form.

    dim toolAdd as ToolBarButton
    dim toolDelete as ToolBarButton 'and so on

Second, in the Load event of my parent form, I set references to the toolbars

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        toolAdd = tbMain.Buttons(ADD_BUTTON)
        toolDelete = tbMain.Buttons(DELETE_BUTTON)
    End Sub

Once set, I can now change properties of the toolbar in my parent form just by coding:

    toolAdd.Enabled = True
    toolDelete.Enabled = False

I think the downside of this though is that you declare a number of public variables (depending on how many parent controls do you need to have access to) which can take up memory space.


Lulu





Quote:
quote:Originally posted by Vince
 Can anyone please advise how I refer to another forms controls in VB.NET

I have one Parent form and two Child forms I want to set the enable properties to false on the parent form toolbar from the child forms. In VB6 it just used to be parent.tbar.button1.enable = false. Now it’s ?????? FRUSTRAITING!!!


 
Old October 20th, 2003, 09:42 AM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i never worked on VB.Net but i think that you can achieve this by

1-in each form that you want to refrence (i.e Form2) declare:
public Shared iForm2 as Form2

2- in the load event of that form
iForm2=ME

you are done .. you can refrence to form2 from any other form by saying: Form2.iForm2.hide forexample.

:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using windows controls in C# cool_hari C# 2 February 14th, 2010 11:02 AM
Ch.14 Creating Windows Form User Controls problem SAIFI BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 1 September 29th, 2008 05:51 AM
C# Windows Form Controls Missing jcrudisill C# 2 August 3rd, 2007 12:32 PM
Windows Custom Controls bmains VB.NET 0 December 21st, 2005 12:17 PM
Custom Controls in Reference bmains VS.NET 2002/2003 0 February 11th, 2004 10:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.