473,808 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting a controls properties from another form

Hi,

I have a project that loads a splash screen while initialization takes
place. On the splash form is a label that I want to update with
messages on what is happening with the initialization. Before the main
form is loaded I show the splash screen and then try to update the
splash label to indicate the status. I cannot figure out the correct
syntax.

Here is a code snippet. My last line generates a
"Error 1 'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStat ion : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStat ion()
{
InitializeCompo nent();
InitializeWeath erStation();
}

// InitializeWeath erstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeath erStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Sh ow();
// Force a refresh so text shows correctly.
SplashScreen.Re fresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labe lStartupStatus. Text = "Hello";

Jan 15 '07 #1
6 4236
Hi,
There are a couple of ways you could do what is required.
1Write a method inside the splashscreen form which takes a string as
an argument. Inside that method you could set the Label.Text property
2Alternatively you could use an event. Pass the string to be
displayed as a eventarg and set the the Label.Text property inside the
eventhandler.
hope this helps...

Jan 16 '07 #2
Hi,

'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible due to its
protection level" means that labelStartupSta tus isn't visible to
formWeatherStat ion. Protection level is the private, protected, public in
front labelStartupSta tus. Try setting it to public. Instead of accessing
the control of another form directly you should go through a property or
method

public String StartupStatus
{
get
{
return labelStartupSta tus.Text;
}
set
{
labelStartupSta tus.Text = value;
}
}

or

public SetStartupStatu s(string status)
{
labelStartupSta tus.Text = status;
}

You may find the splash screen not updating as you want it to, in which
case Application.DoE vents(), threading, invoking, delegates and events are
keywords to look up on.

The article below demonstrates how you can use threading to create a
splash screen.

[A Pretty Good Splash Screen in C#]
http://www.codeproject.com/csharp/Pr...lashScreen.asp

On Mon, 15 Jan 2007 22:01:04 +0100, <su******@hotma il.comwrote:
Hi,

I have a project that loads a splash screen while initialization takes
place. On the splash form is a label that I want to update with
messages on what is happening with the initialization. Before the main
form is loaded I show the splash screen and then try to update the
splash label to indicate the status. I cannot figure out the correct
syntax.

Here is a code snippet. My last line generates a
"Error 1 'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStat ion : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStat ion()
{
InitializeCompo nent();
InitializeWeath erStation();
}

// InitializeWeath erstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeath erStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Sh ow();
// Force a refresh so text shows correctly.
SplashScreen.Re fresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labe lStartupStatus. Text = "Hello";


--
Happy Coding!
Morten Wennevik [C# MVP]
Jan 16 '07 #3
Why not declare labelStartupSta tus as public?

<su******@hotma il.comwrote in message
news:11******** **************@ 11g2000cwr.goog legroups.com...
Hi,

I have a project that loads a splash screen while initialization takes
place. On the splash form is a label that I want to update with
messages on what is happening with the initialization. Before the main
form is loaded I show the splash screen and then try to update the
splash label to indicate the status. I cannot figure out the correct
syntax.

Here is a code snippet. My last line generates a
"Error 1 'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStat ion : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStat ion()
{
InitializeCompo nent();
InitializeWeath erStation();
}

// InitializeWeath erstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeath erStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Sh ow();
// Force a refresh so text shows correctly.
SplashScreen.Re fresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labe lStartupStatus. Text = "Hello";

Jan 16 '07 #4
Hi,

Thanks all for your suggestions and help. How do I declare a label as
public?

Thanks

SurfRat.

Ashot Geodakov wrote:
Why not declare labelStartupSta tus as public?

<su******@hotma il.comwrote in message
news:11******** **************@ 11g2000cwr.goog legroups.com...
Hi,

I have a project that loads a splash screen while initialization takes
place. On the splash form is a label that I want to update with
messages on what is happening with the initialization. Before the main
form is loaded I show the splash screen and then try to update the
splash label to indicate the status. I cannot figure out the correct
syntax.

Here is a code snippet. My last line generates a
"Error 1 'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStat ion : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStat ion()
{
InitializeCompo nent();
InitializeWeath erStation();
}

// InitializeWeath erstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeath erStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Sh ow();
// Force a refresh so text shows correctly.
SplashScreen.Re fresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labe lStartupStatus. Text = "Hello";
Jan 16 '07 #5
Do global search in your project for

private Label labelStartupSta tus

change "private" to "public", that'll do it.

Thank you
<su******@hotma il.comwrote in message
news:11******** *************@l 53g2000cwa.goog legroups.com...
Hi,

Thanks all for your suggestions and help. How do I declare a label as
public?

Thanks

SurfRat.

Ashot Geodakov wrote:
>Why not declare labelStartupSta tus as public?

<su******@hotm ail.comwrote in message
news:11******* *************** @11g2000cwr.goo glegroups.com.. .
Hi,

I have a project that loads a splash screen while initialization takes
place. On the splash form is a label that I want to update with
messages on what is happening with the initialization. Before the main
form is loaded I show the splash screen and then try to update the
splash label to indicate the status. I cannot figure out the correct
syntax.

Here is a code snippet. My last line generates a
"Error 1 'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStat ion : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStat ion()
{
InitializeCompo nent();
InitializeWeath erStation();
}

// InitializeWeath erstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeath erStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Sh ow();
// Force a refresh so text shows correctly.
SplashScreen.Re fresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labe lStartupStatus. Text = "Hello";

Jan 16 '07 #6
Hi,

I got it sorted. Thanks to all for help. I set labelStartupSta tus to
public as suggested which worked. I also tried the class properties
method with the following:

public string StartupStatusTe xt
{
set
{
labelStartupSta tus.Text = value;
}
}

This worked and is the method I settled on. Now working on getting my
splash screen to refresh properly :)

Thanks

SurfRat.

Ashot Geodakov wrote:
Do global search in your project for

private Label labelStartupSta tus

change "private" to "public", that'll do it.

Thank you
<su******@hotma il.comwrote in message
news:11******** *************@l 53g2000cwa.goog legroups.com...
Hi,

Thanks all for your suggestions and help. How do I declare a label as
public?

Thanks

SurfRat.

Ashot Geodakov wrote:
Why not declare labelStartupSta tus as public?

<su******@hotma il.comwrote in message
news:11******** **************@ 11g2000cwr.goog legroups.com...
Hi,

I have a project that loads a splash screen while initialization takes
place. On the splash form is a label that I want to update with
messages on what is happening with the initialization. Before the main
form is loaded I show the splash screen and then try to update the
splash label to indicate the status. I cannot figure out the correct
syntax.

Here is a code snippet. My last line generates a
"Error 1 'WeatherStation .formSplash.lab elStartupStatus ' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStat ion : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStat ion()
{
InitializeCompo nent();
InitializeWeath erStation();
}

// InitializeWeath erstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeath erStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Sh ow();
// Force a refresh so text shows correctly.
SplashScreen.Re fresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labe lStartupStatus. Text = "Hello";
Jan 17 '07 #7

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

Similar topics

2
3754
by: John Hargrove | last post by:
I'm having trouble setting decimal place values in the results field of a sample management database I'm building for an environmental testing laboratory. The degree of sensitivity varies among test methods; consequently, some results are reported to 2 decimal places, some to 3, etc. The Results subform consists of Test Parameter, Result, Report Unit, Analysis Date, Analyst and other fields. The test parameter control is a drop-down...
7
20773
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well. The control populates well, both the display values, and selected values. However, when i try to "set" the SelectedValue or SelectedIndex properties, nothing happens.... The default blank value in the ComboBox is always selected. My code is: ...
1
2382
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their properties, however, there seems to be one that I cannot set - ie, Name.. My code looks like this:
5
3270
by: Alex Glass | last post by:
I have created a winforms application and I designed it with the normal display settings, (96DPI) however, when I set the font settings to 120 DPI, my application text labels look all messed up. Does anyone know a work-around for this problem? Thanks for any advice, Alex
3
3923
by: Mark Rae | last post by:
Hi, Just a general quickie on setting properties of user controls from the parent form. Let's say I have a user control called note.ascx which displays a datagrid. That datagrid is populated according to an integer variable in the ViewState of the parent form. The code behind (still in v1.1) of the user control contains the following:
7
2010
by: Ronald S. Cook | last post by:
In a .NET Windows app, if I set somehting like the title of the form to "MyApp" at run-time, will that make the app run slightly slower than if I had set the title at design-time? Thanks, Ron
6
11092
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
16
4179
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and therefore being able to modify its properties?
9
2523
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett -- comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
0
10631
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10374
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9196
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
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
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.