|
-
Apr 5th, 2004, 07:48 AM
#1
Thread Starter
Frenzied Member
How to declare this variable
Im working with the infragistics ultra tab control. It is very neat way of creating tabs. The easiest way to add info the the tabs is to place all your controls etc in a user control and then add that UC to the tab you want it.
But you can't access the controls like mytab.tab(0).findcontrol("textbox1")
I have therefor written a shared helper class (which infragistics suggested) where you pass a reference to the tab, the ID of the usercontrol and the ID of the control, then it loops through the control collections and return a reference you can work with
like
VB Code:
Dim lbansvarig As ListBox = CType(WebTabHelper.GetChildControlFromUserControl(Me.uwtDriftStopp, "URegistrera1", "lbansvarig"), ListBox)
'btnNewDelete.Enabled = False
dim item as string = lbAnsvarig.Items.Count.tostring
NOW here is my issue... Say I wan to manipulate textbox3 on four different places in a class like reading value, reset value and writing value, in different methods..
Where in my class structure is most appropriate to create the reference? Like I do it now I create all references to all textboxes on page_load... What I really need is only ONE reference that can work with all the textboxes, one for labels etc...
but where in the code is most appropriate to write
dim myTextBox as TextBox ?
Should it infact be a class property???????????????????????????
Or should I write it as public class variables? It feels like this is a common architectural problem,a dn there should be a good way to do it? A pettern perhaps?
I hope you understand my concern?
kind regards
Henrik
-
Apr 5th, 2004, 08:07 AM
#2
PowerPoster
Hi,
Couldn't you use
Public myObject as object
and then
myObject=TextBox1 etc?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 5th, 2004, 08:15 AM
#3
Thread Starter
Frenzied Member
Yeah of course I could do that....
I was more concerned how I would declare the variable itself, not the type it has...
Const
Property
dim
etc...
kind regards
Henrik
-
Apr 5th, 2004, 09:05 AM
#4
PowerPoster
Sorry, I don't follow you. I thought you were saying that you wanted to reduce the number of variables you had to declare.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 5th, 2004, 09:12 AM
#5
Thread Starter
Frenzied Member
Hmm yes.. I was afraid it sounded stupid... 
Using one ref variable is a good way and declaring it as object is also great, but the thing I wanted to know is how I would handle such a variable to maintain encapsulation... Should I declare it a sprivate and put a property around it, or does it look just as nice to have it as a dim in every method where I need to access a particular control?
kind regards
Henrik
-
Apr 5th, 2004, 09:55 AM
#6
PowerPoster
Hi,
I think you have to declare it public or else you might end up with several instances of it. Perhaps you could use the containing object variable in a sub and pass the object you want to reference to that sub by way of a parameter.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|