简体   繁体   English

更新的图标图像不会显示在“文档”标签中

[英]Updated icon image won't show in document tab

I just found DockPanel Suite and am learning to use it. 我刚刚找到DockPanel Suite,正在学习使用它。

I downloaded v2.9 and am using it with C# in VS2013. 我下载了v2.9,并将其与VS2013中的C#结合使用。 I created a simple Windows Forms MDI app. 我创建了一个简单的Windows Forms MDI应用程序。 It has one type of child form which is a simple form with only a rich text box control in it. 它具有一种类型的子窗体,该子窗体是一种简单的窗体,其中仅包含富文本框控件。 I loaded a few of these as documents. 我将其中一些作为文档加载。 I added an icon to the document's tab to indicate whether the rich text box text has been saved or not. 我在文档的选项卡上添加了一个图标,以指示富文本框文本是否已保存。

I change the tab icon anytime the user types in the rich text box through the use of the text_Changed event: 每当用户通过使用text_Changed事件在富文本框中键入内容时,我都会更改选项卡图标:

private void txtCode_TextChanged(object sender, EventArgs e)
    {
        //The text has changed, set the warning icon.
        this.Icon = MyApp.Properties.Resources.Warning;
    }

The problem I have is that the icon does not update when running at full speed. 我的问题是,全速运行时图标不会更新。 It updates fine when I am single stepping through the above event. 当我单步执行上述事件时,它会更新正常。 It also updates fine when I load a file within the form's Load event; 当我在表单的Load事件中加载文件时,它也可以更新。

private void frmCode_Load(object sender, EventArgs e)
    {
        //Get the full file path.
        string sFile = Path.Combine(cCoCoIDE.CodeBaseRootFolder, Path.GetFileNameWithoutExtension(cCoCoIDE.CodeBaseFile), this.Text);

        //Load the source file into the code window.
        //A few validations.
        //Make sure the file exists.
        if (File.Exists(sFile))
        {
            //File is there. Is it empty? Load only if not empty.
            if (new FileInfo(sFile).Length > 0)
            {
                txtCode.LoadFile(sFile);
                //I had to add the following because the text changed
                //event fires when I load the file and I need to start
                //off with the green checkmark icon.
                this.Icon = CoCoIDE.Properties.Resources.GreenChk;
            }
        }

    }

I tried the following after I change the icon (in the Text Changed event): 更改图标后(在“已更改文本”事件中),我尝试了以下操作:

            this.ShowIcon = true;
            this.Refresh();
            this.Update();

Note: I tried these one at a time. 注意:我一次尝试了这些。 The above is just a list of methods. 以上只是方法列表。

Can anyone help me with this? 谁能帮我这个? Thank you! 谢谢! SgarciaV SgarciaV

I found the solution. 我找到了解决方案。 See here: 看这里:

Dockpanel Suite: Image not updating Dockpanel Suite:图片未更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM