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

C# accessing components of an Object

Hello guys,

I am trying to access components of object created suring runtime. Basically the object is a new form and I call it like this:

Expand|Select|Wrap|Line Numbers
  1.             QuickUpdate qu = new QuickUpdate();
  2.             MessageBox.Show(qu.markedToEditLabel.Visible.ToString());
  3.  
The markedToEditLabel is a label and not visible by defualt, the QuickUpdate class uses ShowDialogue method to display the form. While the QuickUpdate form is open I change the visibility of the markedToEditLabel label to true and close the form. The closing of the form is performed by the Hide method placed in the QuickUpdate form it self. Once the form is exited, I would like to find out if the markedToEditLabel label was switched to visible. I checked this with the second line in the code in the MessageBox. However it seems to be forwarding false all the time, even though the visibility was changed to true before closing the QuickUpdate form.

Is there anything I am not doing correctly, or am I just trying to achieve something which is not possible!

Thanks in advance.
Oct 24 '08 #1
3 1124
Curtis Rutland
3,256 Expert 2GB
Well, I think if you hide the form, everything becomes invisible maybe? Anyway, if I were you, I'd set a public bool property that you changed every time you change that label's visibility. Then retrieve that value.
Oct 24 '08 #2
Intersting question:
I created a little test bench and you will need to do what the above post says: when you hide the form, all the controls get their visible property set to false.

Expand|Select|Wrap|Line Numbers
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             if (label1.Visible == true)
  4.             {
  5.                 label1.Visible = false;
  6.             }
  7.             else
  8.             {
  9.                 label1.Visible = true;
  10.             }
  11.         }
  12.  
  13.         private void button2_Click(object sender, EventArgs e)
  14.         {
  15.             Hide();
  16.             MessageBox.Show(label1.Visible.ToString(),"label1 Visible?",MessageBoxButtons.OK);
  17.             Show();
  18.         }
  19.  
  20.         private void button3_Click(object sender, EventArgs e)
  21.         {
  22.             MessageBox.Show(label1.Visible.ToString(), "label1 Visible?", MessageBoxButtons.OK);
  23.         }
button 1 toggles the visibility of label1.
when I press button 2, which hides the form, the MB reports false.
when I press button3, which doesn't hide the form, the visibility of label1 is properly reported.
Oct 24 '08 #3
Great thanks

By using a Public bool was the solution of the problem. Yes apparently when the form is closed all of the drawing components gets false for their visibility. I was actually just trying the first approach because I want to keep the classes as small as possible by using the already created resources, this way it is less confusing.

The whole reason of making the code as little as possible is because the project I am working on is rather big and I am doing this on a personal software so I am the only person who will have to keep the code in working condition all the time.

Thanks again for the help
Oct 24 '08 #4

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

Similar topics

4
by: Jaydeep | last post by:
Hello, I am facing a strange problem. Problem accessing remote database from ASP using COM+ server application having VB components (ActiveX DLL) installed. Tier 1 : ASP front End (IIS 5.0) Tire...
2
by: Mike | last post by:
..NET framework 1.2 Hello. We've been accessing a Java COM component from classic ASP for a while now, which works fine. We now need to access it from .NET, but we have no idea how to...
3
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
3
by: Oleg Skopincevs | last post by:
Hi folks, I am stuck on a problem of creating an object via DCOM from a webservice component. Code: Dim sl As LogonSrv.SysLogon = CreateObject("LogonSrv.SysLogon", LogonServer) Is there...
5
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
1
by: Miku | last post by:
Hi Guies, I am new to vb.net. In my project I am using vb.net & MySql 4.0.17 as a backend. For database connectivity i have downloaded ByteFX - Mysql .net native provider. I have written the...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
1
by: omantawy | last post by:
Hi, I have some legacy ASP web applications that use an unmanaged COM component to connect to a third party application. The third part application has moved to the managed code in the current...
4
by: Lilith | last post by:
This was easy in C++ (well, relatively.) Now I'm in the C# environment and everything I try doesn't work. I'm running a thread in which I have two accesses I need to components on a form. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.