473,395 Members | 1,368 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,395 software developers and data experts.

Setting text in textbox through another class

Hi,

I am spawning a thread from Form1 which has a worker method in anther class(Class1). At the end of the worker method I want to set the text of a Text Box in the Form1 as the result of the computation of the worker method. Writing "TextBox1.Text = string" in worker method of Class1 doesnt work although the string has the right value in it.
Can someone please explain how to do this in simple steps ?

Thanks
May 19 '09 #1
3 3951
IanWright
179 100+
I would actually expect you to get an Exception to be honest attempting to do that, telling you that you can't update it because the thread doesn't own the textbox...

I don't have time to write out a full answer.. take a look at:
http://www.ianwright.talktalk.net/pa...ading/gui.html

under the 'Updating Interface from Processing Thread' title. It's just a little site I setup for reference so it's not very detailed but if you use that layout to update your textbox then I imagine it'll work.
May 19 '09 #2
Why dont you try using the properties to do this. Set the value of the property in your class, Come back to your form and assign the value to the textbox from your form.
May 19 '09 #3
r035198x
13,262 8TB
Better read about and use a BackgroundWorker for your task.
May 19 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
6
by: MLH | last post by:
You know how the text in the attached label sort of 'greys out' when you click something that sets MyTextbox.Enabled = False? I would like to make a label's text look like that? How do I do it?...
1
by: John Morey | last post by:
I have a Text Box in my program that takes user input , it has multiline set to true , and will automatically clear the text box when the enter key is pressed (after passing it to another "engine"...
1
by: Rachel Suddeth | last post by:
I have an form where the whole display is a tab control (well, that plus a status bar.) I want to set the focus to the first TextBox on the first TabPage when it loads. I tried to put that into...
4
by: Gill Smith | last post by:
After setting the web control text box enable property to FALSE makes the control to loose the data between round trip. I am making sure that the property - EnableViewState = TRUE. Same code...
9
by: Aaron Smith | last post by:
I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it...
5
by: UJ | last post by:
I have a user control that inherits from the standard windows text box. I have a routine that adds stuff to it. I have compiled it into a dll. I have added it to my app and I can debug into it. I...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
1
by: DeanB | last post by:
Please excuse my ignorance here as I have not used WPF for long, but what is the statement that tells what the "local:" identifier is that allows a window event to call a function in a .cs file? ...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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.