|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
to control from class1. I thought I could send a referense to the label but I don't know how to do that in VB How do I declare the referens in class2??? I need to change color+text from class2 Public Class Clas1 Inherits System.Windows.Forms.UserControl Friend WithEvents lblStatus As System.Windows.Forms.Label private cl As new Class2 Cl = new Class2(lblStatus) End class Public Class Class2 Public Sub New(ByRef instLblText As System.Windows.Forms.Label) Init() End Sub Private Sub Init() 'I need here to give instLblText a green background ans chande it's color and update the grafic in clas one where the label is shown End Sub End class -- LZ
Show quote
Hide quote
"Lamis" <La***@discussions.microsoft.com> schrieb You don't have to pass it ByRef here. See also:> i have 2 forms.. one is windows form and I have a lable there that i > do want to control from class1. I thought I could send a referense > to the label but I don't know how to do that in VB > How do I declare the referens in class2??? I need to change > color+text from class2 > > > Public Class Clas1 > Inherits System.Windows.Forms.UserControl > Friend WithEvents lblStatus As System.Windows.Forms.Label > private cl As new Class2 > > Cl = new Class2(lblStatus) > End class > > Public Class Class2 > > Public Sub New(ByRef instLblText As System.Windows.Forms.Label) http://groups.google.com/group/microsoft.public.dotnet.languages.vb/msg/41e83beb9988aabf > Init() 3 ways:> End Sub > > Private Sub Init() > 'I need here to give instLblText a green background ans chande > it's color and update the grafic in clas one where the label is > shown > End Sub > End class a) Change the color in Sub New - you already have the reference there: instLblText.backcolor = color.green b) Pass the reference to Sub Init: Public Sub New(ByVal instLblText As System.Windows.Forms.Label) Init(instLblText) End Sub Sub Init (Byval lbl As System.Windows.Forms.Label) lbl.backcolor = color.green end sub c) Store the reference in a field - if you also need it later, not only in sub New: private f_Label as label Public Sub New(ByVal instLblText As System.Windows.Forms.Label) f_label = instLblText Init() End Sub Sub Init () f_label.backcolor = color.green end sub Apart from this, I wonder why you want to pass the label at all. Isn't it possible to do the same in Class1. I mean, that's (usually) what the Usercontrol is used for. Armin
vs2005 - Why all the errors? yet the code works.
VB2005 - Stop User from Leaving Row in DataGridView Foreign Characters in XML Cell validating event problem. Multiple columns in Combobox list ObjectContext problem Migration of MSFLEXGRID to DATAGRID in vb.net... Insert Column in Excel in VB .NET Old value of a datagridview combobox cell Converting from VB6 to VB.NET 2003 |
|||||||||||||||||||||||