PC Review


Reply
Thread Tools Rate Thread

combo box linking to a textbox

 
 
=?Utf-8?B?aXdkdTE1?=
Guest
Posts: n/a
 
      7th Aug 2005
hi, this is the code i have to put the text ina combo box thats being show
into a text box

Private Sub cmbteams_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbteams.SelectedIndexChanged

If cmbteams.SelectedIndex <> -1 Then
Me.TextBox1.Text = Me.cmbteams.SelectedItem
End If

End Sub

then, if i try to call it later from a different form to see what the text
is, all it shwos is "TextBox1", heres how i call it

Private Sub lblaa5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblaa5.Click
Me.lblaa5.Text = team.TextBox1.Text
End Sub

lblaa5 is a label on one of my forms, its text is what i want to be the same
as the other form(team)'s textbox to be when i click on the label

thanks
 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      7th Aug 2005
iwdu15

Try to set in top of your program or your in your options
Option Strict On it will warn you for the kind of errors you probably get
now.

With Option Strict Off, your program is in a kind of VB6 compatible state.

You will than see that moving the value of the Combobox (not linking) will
be
Textbox1.Text = Combobox1.SelectedItem.ToString

The other problem, you needs what kind of forms you use.
For that is needed that you tell how you show your form, which can be as a
child of your parentform, the owner. As a Mdiform or as a dialog
(showdialog) or a complete seperated form started in a module.

I hope this helps,

Cor





 
Reply With Quote
 
=?Utf-8?B?aXdkdTE1?=
Guest
Posts: n/a
 
      7th Aug 2005
I use the .show command to show it, but i have it so its always on top, but i
did the code u showed me and put "option strict on" and it still didnt work,
it still shows "TextBox1"
 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      7th Aug 2005
iwdu15,

Can you show us the code that you used?

As well which you use to create that second form

Cor


 
Reply With Quote
 
=?Utf-8?B?aXdkdTE1?=
Guest
Posts: n/a
 
      7th Aug 2005
sure, heres how i declare the second form:

Dim team As New pickateam

pickateam being the form with the textbox on it

heres how i open it:

Dim frm As New pickateam
frm.Show()

and the rest of the code i already showed but il post again


Private Sub cmbteams_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbteams.SelectedIndexChang
If cmbteams.SelectedIndex <> -1 Then
Me.TextBox1.Text = Me.cmbteams.SelectedItem.ToString
End If

End Sub

then to get the text from the textbox:

Private Sub lblaa1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblaa1.Click
Me.lblaa1.Text = team.TextBox1.Text
End Sub

 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      7th Aug 2005
iwdu15

It is strange that the code you show does not work.

To be sure I tested it again

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.Owner = Me
frm.Show()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal _
sender As System.Object, ByVal e As System.EventArgs) _
Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.SelectedItem.ToString
End Sub
///
And then form2 as you want
\\\
Private Sub Button1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = DirectCast(Me.Owner, Form1).TextBox1.Text
End Sub
////

I hope this helps,

Cor



 
Reply With Quote
 
=?Utf-8?B?aXdkdTE1?=
Guest
Posts: n/a
 
      8th Aug 2005
hi, i figured out the problem, i accidently declared the form as 2 different
names and used one to open it and the other to say what the textbox was...so
thanks anyway
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking a form combo box... results from the combo box to another =?Utf-8?B?VHJleQ==?= Microsoft Excel Misc 1 15th Jul 2007 01:58 AM
textbox linking to another form =?Utf-8?B?VGRhaGxtYW4=?= Microsoft Access 5 2nd Aug 2006 06:49 PM
Linking a cell to a textbox =?Utf-8?B?R2Vvcmdl?= Microsoft Excel Programming 8 11th Jan 2006 09:13 PM
linking 2 form with a textbox... help please! =?Utf-8?B?VGFoYW5p?= Microsoft Access 1 16th Mar 2005 02:46 PM
ListBox and TextBox Linking Pacific Design Studios Microsoft VB .NET 0 26th Aug 2003 05:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:47 PM.