473,516 Members | 3,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2428
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
3330
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 about in the submitted action. I'd therefore like to get rid of them by doing something like:
2
2617
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 form is opened. After the user selects the contact from an unbound combobox I want the form to be rebound to its recordsource. I tried using...
4
2429
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. The first class handles the form generation - (this was done using GUI form designer).
3
2988
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, System.EventArgs e) {try{ DataSet ds = dgMembers.DataSource as DataSet;
3
2658
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 forms1 I've placed two components a NotifyIcon and FileSystemWatcher. I created a event handler called onchanged which responds to file being created...
7
2932
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 already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
6
6864
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 comboBox1_SelectedIndexChanged that is on B but I dont know how to send that info to the label on A.I cant seem to access A from B. Help Thanks Mike
5
57776
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 my code, at runtime to "Number of bikes".
8
28515
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
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7574
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.