[URGENT] VB.NET : TabControl, TabPages and UserControl Communication

C

ChrisK

Hi,

I'm beginner with VB.net and i have a trouble... At work, they decided
to program with tabcontrol...and i'mm in charge of this !

There is my problem.
I've a form with one tabcontrol (TBC1 ). This TBC1 contents n TabPages
( TBP1,2,3,..,n)
For each TBPn i 've got an specific usercontrol which have controls
and code ( data access, ... ).
I want to establish dialog between the different TBP starting from any
usercontrol.

For example :

TBP1 = UserControl1 (UC1) with ComboBox and CommandButton
TBP2 = UserControl2 (UC2) with textBox, checkBox, ComboBox and
CommandButton

When I choose an item in the ComboBox of UC1, i Click on CommandButton
to fill controls of UC2.
Finally i want to show TBP2.

I hope it was clear, cos' i'm not speaking english very well, but i
understand quiet well!
Briefly my question is :
How can two USercontrols of different tabpages communicate ?

Thnks for your answers

Best Regards From Paris

Mail_taf
 
P

Peter Proost

You can use property's,

for example at uc1 (user control1) you can have a property and a variable:

Private strCode
Public Property code()
Get
return strCode 'can also be textbox.text or whatever you want, but I'd
advice to return 'variables
End Get
Set(ByVal Value)
strCode = value
End Set
End Property

and at uc2 you also have a property named code

Private strCode
Public Property code()
Get
return strCode
End Get
Set(ByVal Value)
strCode = value
End Set
End Property

than on the form where the user controls are on you can do:

uc2.code = uc1.code
hth

Peter
 
C

Cor Ligthert

Hi Chris,

I thought that I answered this as well in the general group.

You place normally your usercontrols globaly (friend) on your form,
therefore they can "talk" to each other everywhere in that class.

Therefore the only thing in my opinion that you have to do is as I as well
said in the general newsgroup is to select the right tabpage. indexof which
is a number from 0 to your last page or the tabcontrol.

http://msdn.microsoft.com/library/d...ndowsformstabcontrolclassselectedtabtopic.asp

However the question seems something else so where do I not understand you?



Cor
 
P

Peter Proost

Hi Cor,

I think he just want's to get some values from one usercontrol to an other
usercontrol

Peter
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
I thought that I answered this as well in the general group.

You place normally your usercontrols globaly (friend) on your form,
therefore they can "talk" to each other everywhere in that class.

The fact that the instances can talk to each other doesn't have much to do
with their modifier. I suggest to set the usercontrol's modifier to
'Protected' (or 'Private'). Notice that this still won't prevent the
usercontrols from communicating.
 
C

Cor Ligthert

Herfried,

I can be wrong, however I thought that when you drag them on your form they
are automaticly set to Friend, that was what I tried to tell.

I see personally not much reasons to change that, however maybe you do not
mean that?

Cor

"Herfried K. Wagner [MVP]"
...
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
I can be wrong, however I thought that when you drag them on your form
they are automaticly set to Friend, that was what I tried to tell.
ACK.

I see personally not much reasons to change that, however maybe you do not
mean that?

Well, that's personal preference... I don't want to see the controls in
IntelliSense when I work on a variable holding a form's instance.
 
C

Cor Ligthert

Peter,

That is what I think as well, however that depends how he build them in my
opinion. When the properties in those controls are friend (or Public) than
that should be very easy when those usercontrols are in the same form class.
However maybe I miss something,

Cor
 
P

Peter Proost

Cor,

I don't think you're missing something because I understood the question in
the same way, or maybe we're both missing something ;-)

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top