"Dim N As New Form1()"
Is the incorrect line, this creates a new instance of Form1 instead of
referencing the existing Form1 Instance..
You will need to pass a reference into Form2, either for the Instance of
Form1 you currently have or for the specific textbox on Form1 you wish to
change. (I'd go for the second option, as you can then use it with other
textboxes also.. reusable code..).
So in Form2, create a TextBoxToAlter Property (or some such).. then when you
create Form2, set the Form2.TextBoxToAlter = Me.TextBox1 (Assuming you're
starting Form2 from Form1)
Then in Form2, use Me.TextBoxToAlter.ForeColor = Color.Blue etc.....
Rigga.
"shal" <(E-Mail Removed)> wrote in message
news:F9C28C83-9212-4601-AE77-(E-Mail Removed)...
> hello:
>
> I am trying to change text color of the textbox1 from another form named
Form2. i am using following code right now but it doesnt change property of
textbox1. can you tell me whats wrong here? thanks!!
>
> Code in Form1 that has Text box named Textbox1
>
> // this linedoes do anything it jsut shows theres one textbox1 insdie form
one
>
> Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
> End Sub
>
> // if user clicks on the button another form pops up with radio buttons
where you can select color
>
> Private Sub BtnOptions_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnOptions.Click
> Dim N As New Form2()
> N.Show()
> End Sub
>
> // after selecting particular radio button user clicks ok, so text color
in side text box in form1 should change..
>
> Private Sub btnOkF2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOkF2.Click
> Dim N As New Form1()
> If RadioButton1.Checked = True Then N.TextBox1.ForeColor =
System.Drawing.Color.Blue
> If RadioButton2.Checked = True Then N.TextBox1.ForeColor =
System.Drawing.Color.Red
> If RadioButton3.Checked = True Then N.TextBox1.ForeColor =
System.Drawing.Color.Green
> If RadioButton4.Checked = True Then N.TextBox1.ForeColor =
System.Drawing.Color.Black
> If RadioButton5.Checked = True Then N.TextBox1.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
> If RadioButton6.Checked = True Then N.TextBox1.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
> N.TextBox1.Text = "Hellow World!"
> Me.Hide()
>
>
> End Sub
>
> above code should change Text color in From1 Textbox1 but it doenst change
color!! i dont know what is wrong with the code as it compiles without any
error.
> please help!!
|