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

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.labelStartupStatus' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStation : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStation()
{
InitializeComponent();
InitializeWeatherStation();
}

// InitializeWeatherstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeatherStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Show();
// Force a refresh so text shows correctly.
SplashScreen.Refresh();

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

Jan 15 '07 #1
6 4220
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.labelStartupStatus' is inaccessible due to its
protection level" means that labelStartupStatus isn't visible to
formWeatherStation. Protection level is the private, protected, public in
front labelStartupStatus. 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 labelStartupStatus.Text;
}
set
{
labelStartupStatus.Text = value;
}
}

or

public SetStartupStatus(string status)
{
labelStartupStatus.Text = status;
}

You may find the splash screen not updating as you want it to, in which
case Application.DoEvents(), 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******@hotmail.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.labelStartupStatus' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStation : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStation()
{
InitializeComponent();
InitializeWeatherStation();
}

// InitializeWeatherstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeatherStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Show();
// Force a refresh so text shows correctly.
SplashScreen.Refresh();

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


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

<su******@hotmail.comwrote in message
news:11**********************@11g2000cwr.googlegro ups.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.labelStartupStatus' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStation : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStation()
{
InitializeComponent();
InitializeWeatherStation();
}

// InitializeWeatherstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeatherStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Show();
// Force a refresh so text shows correctly.
SplashScreen.Refresh();

// Try to access Weatherlink.dll and catch any errors.
formSplash.labelStartupStatus.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 labelStartupStatus as public?

<su******@hotmail.comwrote in message
news:11**********************@11g2000cwr.googlegro ups.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.labelStartupStatus' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStation : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStation()
{
InitializeComponent();
InitializeWeatherStation();
}

// InitializeWeatherstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeatherStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Show();
// Force a refresh so text shows correctly.
SplashScreen.Refresh();

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

private Label labelStartupStatus

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

Thank you
<su******@hotmail.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.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 labelStartupStatus as public?

<su******@hotmail.comwrote in message
news:11**********************@11g2000cwr.googlegr oups.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.labelStartupStatus' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStation : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStation()
{
InitializeComponent();
InitializeWeatherStation();
}

// InitializeWeatherstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeatherStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Show();
// Force a refresh so text shows correctly.
SplashScreen.Refresh();

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

Jan 16 '07 #6
Hi,

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

public string StartupStatusText
{
set
{
labelStartupStatus.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 labelStartupStatus

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

Thank you
<su******@hotmail.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.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 labelStartupStatus as public?

<su******@hotmail.comwrote in message
news:11**********************@11g2000cwr.googlegro ups.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.labelStartupStatus' is inaccessible
due to its protection level". How do I fix this?

Thanks

SurfRat.

namespace WeatherStation
{

public partial class formWeatherStation : Form
{

// WeatherStation Constructor
/// <summary>
/// WeatherStation Constructor.
/// </summary>
public formWeatherStation()
{
InitializeComponent();
InitializeWeatherStation();
}

// InitializeWeatherstation
/// <summary>
/// Checks Weatherlink.Dll and com port access.
/// </summary>
public void InitializeWeatherStation()
{
// Instantiate a Splash screen and show it.
formSplash SplashScreen = new formSplash();
SplashScreen.Show();
// Force a refresh so text shows correctly.
SplashScreen.Refresh();

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

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

Similar topics

2
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...
7
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....
1
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...
5
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. ...
3
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...
7
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
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...
16
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...
9
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 --...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
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
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...

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.