Solved

user control refresh issue

Posted on 2011-03-14
12
225 Views
Last Modified: 2012-08-13
Hi Experts,
I have a problem related to the refresh method of a usercontrol:
I've implemented a usercontrol containing a label and button. I've implementet a method which
change the label color when the button is pressed and it works.
The usercontrol is iserted inside a tabcontrol. When I try to recall the same refresh logic of the button inside
the on_tabindexchanged method of the tabcontrol, I can see by debugg that the code is executed
and the color attribute of the label is correct, but it is not displayed. I've also tried to call the invalidate,
refresh, application.doevents methods but nothing happens (the label remains in the original color)
Thanks for help.
0
Comment
Question by:dionisio_79
  • 7
  • 5
12 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35133394
Can we see your code in the tabindexchanged() event?
0
 

Author Comment

by:dionisio_79
ID: 35133565
I don't have the original source code here (tomorrow morning I will)   but it is something like:

 tabindexchanged(..)
{
a.methodxx()
}

where a is the usercontrol object which has been added in the tabcontrol constructor.

the methodxx  is the same method used inside the a.button1_click method
it changse the color of the label: label1.forecolor=color.yellow
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35133620
"which has been added in the tabcontrol constructor"

So you are using a custom TabControl?  What kind of modifications have you made?

Give us the "big picture" please.
0
 

Author Comment

by:dionisio_79
ID: 35133798
Sorry,
 you're right.

The usercontrol has been added to one tab of the tabcontrol, which is owned by the main class (extends form).
Anyway, I will send you a complete code sample tomorrow.

Thank you.




0
 

Author Comment

by:dionisio_79
ID: 35136646
Hi All,

here's the code sample:


gpcl : UserControl
{

....
private void button1_Click(object sender, EventArgs e)
{
            methodxx();
}

....
public void methodxx(){label1.color=color.yellow}
this.Invalidate();
this.Refresh();
Application.DoEvents();
....

}


-----------------------------------------------------------------

mainclass: form

 private TabPage tabXX;
 private gpcl GP;

 public mainclass()
{
         
           InitializeComponent();
            this.Load += new EventHandler(mainclass_Load);
            LoadControl();

}

InitializeComponent()
{
...
tabXX= new System.Windows.Forms.TabPage();
}

void mainclass_Load(object sender, EventArgs e)
{
         GP = new gpcl();
          GP.Location = new System.Drawing.Point(0, 3);
         GP.Size = new System.Drawing.Size(794, 361);
                        tabXX.Controls.Add(GP);

}

 private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
         if (...tab index is th one interested..)  
                   GP.methodxx();
           
        }

}
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35137657
I'm not seeing the issue in your sample code.

What is LoadControl() doing though?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dionisio_79
ID: 35138455
The LoadControl method only assigns a text to the text property of the label:

lebel1.text="..sometext..";
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35138710
You probably just didn't post it...but I don't see where you're adding "tabXX" (your tabpage) to the TabControl.
0
 

Author Comment

by:dionisio_79
ID: 35139106
In the designer (InitializeComponent method):

this.tabControl.Controls.Add(this.tabXXi);
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35139142
Anyway you can upload a bare minimum project that has this issue?
0
 

Accepted Solution

by:
dionisio_79 earned 0 total points
ID: 35139682
Sorry, I don't have permission for this (it is not my own code).
Possibly, when I have time, I will create my own project just to work it out.
Thank you anyway.
0
 

Author Closing Comment

by:dionisio_79
ID: 35221175
I had not a complete sample so Experts were'nt able to halp me
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office.Interop.Word Document - Detect Macros not working 16 36
bulid json format 3 45
COnsume rest client 6 36
Runtime Error 2 28
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now