473,390 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Changing text box property from another form

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 Textbox

// this linedoes do anything it jsut shows theres one textbox1 insdie form on

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChange
End Su

// if user clicks on the button another form pops up with radio buttons where you can select colo

Private Sub BtnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOptions.Clic
Dim N As New Form2(
N.Show(
End Su

// 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.Clic
Dim N As New Form1(
If RadioButton1.Checked = True Then N.TextBox1.ForeColor = System.Drawing.Color.Blu
If RadioButton2.Checked = True Then N.TextBox1.ForeColor = System.Drawing.Color.Re
If RadioButton3.Checked = True Then N.TextBox1.ForeColor = System.Drawing.Color.Gree
If RadioButton4.Checked = True Then N.TextBox1.ForeColor = System.Drawing.Color.Blac
If RadioButton5.Checked = True Then N.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3
If RadioButton6.Checked = True Then N.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingl
N.TextBox1.Text = "Hellow World!
Me.Hide(
End Su

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!!
Nov 20 '05 #1
2 2415
Cor
Hi Shal,

When you handle your optionform as a dialog form it becomes very easy.
You make a property (or just a public field) in your optionform
Private Sub BtnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOptions.Click Dim N As New Form2() N.Showdialog
mycolor = N.myoptioncolor
N.dispose End Sub

I hope this helps?

Cor
Nov 20 '05 #2
"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" <sh*************@msn.com> wrote in message
news:F9**********************************@microsof t.com...
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!!

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
2
by: ColinWard | last post by:
Hi. I have a form which has as its recordsource an SQL string. The SQL String is as follows: SELECT * from CONTACTS where false. this ensures that there is no data loaded in the form when the...
4
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. ...
3
by: Doug | last post by:
Hi I have the following code (not mine) that populates a datagrid with some file names. But I want to replace the datagrid with a combo box. private void OnCurrentDataCellChanged(object sender,...
3
by: Mike Johnson | last post by:
I'm new to VB.Net and programming. I just brought VB.Net Standard I'm working on a small program for work. I've created two forms the first is named Forms1 and the second is named SettingsForm on...
7
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
6
by: AMP | last post by:
Hello, I have an mdi program with a child form ("A") and another child ("B"). I want to change the text of a label on A by changing an item from a combobox on B. I can code the...
5
by: Kimmo Laine | last post by:
Hi is there a way to change propertys attribute from the code? Letīs say that i have the following property in my class: public int Count } Is there a way to change the displayname, from...
8
by: Steve | last post by:
Hi All Is there a way to change the colour of a Groupbox border in VB.net 2005 I want to change it to white Can it be done in the onpaint event? Regards Steve
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.