Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 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 May 17th, 2006, 02:38 AM
Registered User
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Button enable property - Late binding

Dear Friends

I have number of buttons like add, edit, save, etc. in different forms (in more than 50 forms) If one button is clicked other buttons' enabled property will be true or false in a particular form.

I want one method which will be written in a module or in a class. This will be used to control all buttons in various forms. Please give sample coding for this.

'This is in one form1

Private Sub cmdAdd_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdAdd.Click


   End Sub

Public Sub btnAddStatus()

      cmdAdd.Enabled = False
      cmdEdit.Enabled = False
      cmdSave.Enabled = True
      cmdDelete.Enabled = False
      cmdView.Enabled = False

   End Sub

I want like this as below
************************************************** *********
Private Sub cmdAdd_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdAdd.Click


   End Sub

Module Test

public sub btnAddStatus(byval obj as Object)

           obj.cmdAdd.Enabled = False
           obj.cmdEdit.Enabled = False
           obj.cmdSave.Enabled = True
           obj.cmdDelete.Enabled = False
           obj.cmdView.Enabled = False

end sub

End Module

is it possible to make a common method to activate buttons. Please
rectify the error and send.
Old June 12th, 2006, 03:20 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts


Why not use findcontrol instead, instead of passing an object (which you can't pass the object) like that. You could make that method a custom page class method which all your pages inherit from.

public class CustomPageClass
  public sub ChangeStatus(objStatus as CurrentStatus)
     Dim cmdAdd As Button = Me.FindControl("cmdAdd")
     if (cmdAdd IsNot Nothing) Then cmdAdd.Enabled = ..

  end sub
end class

Old June 18th, 2006, 09:44 AM
Authorized User
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

Since you are using .NET 2.X, you can use "My" Object

The My.Application.OpenForms gives a Collection of currently open Forms

Then, you can iterate through the forms collection and then set

foreach frmSet in My.Application.OpenForms
And so on :)

The .NET Underground Portal

Similar Threads
Thread Thread Starter Forum Replies Last Post
Late Binding with COM DLL Rajashekhar G H Access 1 November 4th, 2011 01:33 PM
late binding meghaljani BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 6 August 22nd, 2008 07:06 PM
late binding,help? alexcym Visual Basic 2005 Basics 2 April 7th, 2008 03:26 PM
Late Binding Blade XML 3 July 17th, 2003 06:49 AM

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