需要帮助刷新用户控件 [英] Need help with refreshing user controls

查看:98
本文介绍了需要帮助刷新用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我试图弄清楚如何刷新用户控件,我试过UserControl1.Refresh();但它似乎没有做任何事情。我需要它,所以它刷新每个usercontrol里面的listviews,总共9个。



这是最好的方法。



提前致谢。



我的编码示例



Hello there, I am trying to figure out how to refresh a user control, I have tried UserControl1.Refresh(); but it seems that it not doing anything. I need it so it refresh the listviews inside each usercontrol which is a total of 9.

What be the best possible method around this.

Thanks in advance.

Example of my coding

  private void refreshTheme()
        {
            /*
             uc_advancedWarfare.Invalidate();
             uc_blackOps.Invalidate();
             uc_blackOps2.Invalidate();
            uc_blackOps3.Invalidate();
            uc_ghosts.Invalidate();
            uc_modernWarfare2.Invalidate();
            uc_modernWarfare3.Invalidate();
            uc_mw.Invalidate();
            uc_waw.Invalidate();
            */

/*
             uc_advancedWarfare.Refresh();
             uc_blackOps.Refresh();
             uc_blackOps2.Refresh();
            uc_blackOps3.Refresh();
            uc_ghosts.Refresh();
            uc_modernWarfare2.Refresh();
            uc_modernWarfare3.Refresh();
            uc_mw.Refresh();
            uc_waw.Refresh();
            */



            //this.Refresh();
            var controls = new UserControl[]
            {
                this.uc_advancedWarfare,
                this.uc_blackOps,
                this.uc_blackOps2,
                this.uc_blackOps3,
                this.uc_ghosts,
                this.uc_modernWarfare2,
                this.uc_modernWarfare3,
                this.uc_mw,
                this.uc_waw
            };

            foreach (var uc in controls)
            {
                if (uc == null)
                    continue;

                uc.BackColor = this.BackColor;
            }
        }





我的尝试:



我只试过以下



UserControl1.Refresh();

UserControl1.Invalidate ();



What I have tried:

I have only tried the following

UserControl1.Refresh();
UserControl1.Invalidate();

推荐答案

尝试

Try
MyUserControl.Invalidate();

UserControl.Invalidate方法(System.Windows。表格) [ ^ ]


我很确定你必须阅读: c# - UserControl Invalidate()方法。如何正确地使UserControl中的子控件无效? [ ^ ]



注意:

你没有解释invalidate方法有什么问题,但我想,UserControl的嵌套控件不会失效。
I'm pretty sure that you have to read this: c# - UserControl Invalidate() method. How to properly invalidate the child controls in a UserControl?[^]

Note:
You didn't explain what's wrong with invalidate method, but i guess, nested controls of UserControl aren't invalidated.


这篇关于需要帮助刷新用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆