| | |
Accesing controls on the form from custom method
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi,
Here's what I've got:
Visual Studio 2005
C# Application with form and a label on it
(This is a simplified project
)
Here's what I'd like to do:
I want to change text on the label from the method I'll create. Looks simple... If I'll create a button which will change a label's text, it works. But if I want to change it from method I've created on my own, it's impossible... I just don't see any label in my method... Is there some way to access it?
Thanks, Steve
Here's what I've got:
Visual Studio 2005
C# Application with form and a label on it
(This is a simplified project
)Here's what I'd like to do:
I want to change text on the label from the method I'll create. Looks simple... If I'll create a button which will change a label's text, it works. But if I want to change it from method I've created on my own, it's impossible... I just don't see any label in my method... Is there some way to access it?
Thanks, Steve
Last edited by Stivi; Aug 27th, 2006 at 2:05 pm.
Hi,
As you see you have to call your own method from somewhere.
Loren Soth
C# Syntax (Toggle Plain Text)
void change(string s) { label1.Text = s; } private void button1_Click(object sender, System.EventArgs e) { change("Hakan"); }
As you see you have to call your own method from somewhere.
Loren Soth
Best regards,
Loren Soth
Crimson K. Software _________________________________________________________________ Crimson K. Blog
Loren Soth
Crimson K. Software _________________________________________________________________ Crimson K. Blog
![]() |
Similar Threads
- print large pricturebox or form in vb6 (Visual Basic 4 / 5 / 6)
- Pass Controls of Access-Form to sub in module (Visual Basic 4 / 5 / 6)
- Using Windows XP Visual Styles with Controls on Windows Forms (VB.NET)
- Creating new controls through code. (VB.NET)
- applet not showing up (Java)
- Posting values to a payment gateway without using a form (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: improve events speed
- Next Thread: Append in xml document
Views: 2468 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development drawing encryption enum event excel file files form format ftp function gcd gdi+ http httpwebrequest image index input java list listbox listener login mandelbrot math mouseclick mysql networking object oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





