Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

user control refresh issue

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
dionisio_79
Asked:
dionisio_79
  • 7
  • 5
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Can we see your code in the tabindexchanged() event?
0
 
dionisio_79Author Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
dionisio_79Author Commented:
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
 
dionisio_79Author Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I'm not seeing the issue in your sample code.

What is LoadControl() doing though?
0
 
dionisio_79Author Commented:
The LoadControl method only assigns a text to the text property of the label:

lebel1.text="..sometext..";
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You probably just didn't post it...but I don't see where you're adding "tabXX" (your tabpage) to the TabControl.
0
 
dionisio_79Author Commented:
In the designer (InitializeComponent method):

this.tabControl.Controls.Add(this.tabXXi);
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Anyway you can upload a bare minimum project that has this issue?
0
 
dionisio_79Author Commented:
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
 
dionisio_79Author Commented:
I had not a complete sample so Experts were'nt able to halp me
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now