winforms 在winform中显示toolStripProgressBar1和toolStripLabel1时,前一位置的listView1不会消失

deyfvvtc  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(119)

我在c# winform中有一个代码实现。输入框是ToolStripTextBox,显示在最上面一行。进度栏ToolStripProgressBar在ToolStripTextBox下面。进度栏ToolStripLabel的进度在ToolStripProgressBar下面。
DoubleBufferListView显示在ToolStripLabel下方。
但是,在显示ToolStripProgressBar和ToolStripLabel时,它们的位置仍然显示DoubleBufferListView的第一项。
代码如下:

using CommonTools;
    using System.Drawing;
    using System.Windows.Forms;

    namespace EWPEditor.Plugin.UI
    {
    partial class MainPane
    {
        /// \
        /// Required designer variable.
        /// \
        private System.ComponentModel.IContainer components = null;

        ///  
        /// Clean up any resources being used.
        /// 

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
    
        #region Component Designer generated code
    
        ///  
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// 
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton13 = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripButton8 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStripSplitButton3 = new System.Windows.Forms.ToolStripSplitButton();
            this.手册ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.打开ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.编辑ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.导入本地内容ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.收藏选中内容ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.插入选中内容ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.删除选中内容ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.imageList1 = new System.Windows.Forms.ImageList(this.components);
            this.导出文档ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.panel1 = new System.Windows.Forms.Panel();
            this.listView1 = new CommonTools.DoubleBufferListView();
            this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new  System.Windows.Forms.ColumnHeader()));
            this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
            this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
            this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
            this.toolStrip2 = new System.Windows.Forms.ToolStrip();
            this.toolStrip1.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.panel1.SuspendLayout();
            this.toolStrip2.SuspendLayout();
            this.SuspendLayout();
            // 
            // toolStrip1
            // 
            this.toolStrip1.Font = new System.Drawing.Font("Microsoft YaHei", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
            this.toolStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripSeparator3,
            this.toolStripButton4,
            this.toolStripButton13,
            this.toolStripSeparator2,
            this.toolStripButton8,
            this.toolStripButton2,
            this.toolStripSplitButton3});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(210, 33);
            this.toolStrip1.TabIndex = 1;
            this.toolStrip1.Text = "toolStrip1";
            // 
            // toolStripButton1
            // 
            this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton1.Image = global::EWPEditor.Plugin.Properties.Resources.Webdev_arrow_up;
            this.toolStripButton1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(30, 30);
            this.toolStripButton1.Text = "上一级";
            this.toolStripButton1.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
            this.toolStripButton1.ToolTipText = "上一级";
            this.toolStripButton1.Click += new System.EventHandler(this.ToolStripButton1_Click);
            // 
            // toolStripSeparator3
            // 
            this.toolStripSeparator3.Name = "toolStripSeparator3";
            this.toolStripSeparator3.Size = new System.Drawing.Size(6, 33);
            // 
            // toolStripButton4
            // 
            this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton4.Image = global::EWPEditor.Plugin.Properties.Resources.Webdev_add;
            this.toolStripButton4.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton4.Name = "toolStripButton4";
            this.toolStripButton4.Size = new System.Drawing.Size(30, 30);
            this.toolStripButton4.Text = "一键插入";
            this.toolStripButton4.ToolTipText = "一键插入";
            this.toolStripButton4.Click += new System.EventHandler(this.ToolStripButton4_Click);
            // 
            // toolStripButton13
            // 
            this.toolStripButton13.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton13.Image = global::EWPEditor.Plugin.Properties.Resources.Webdev_reload;
            this.toolStripButton13.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.toolStripButton13.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton13.Name = "toolStripButton13";
            this.toolStripButton13.Size = new System.Drawing.Size(30, 30);
            this.toolStripButton13.Text = "刷新";
            this.toolStripButton13.Click += new System.EventHandler(this.ToolStripButton13_Click);
            // 
            // toolStripSeparator2
            // 
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new System.Drawing.Size(6, 33);
            // 
            // toolStripButton8
            // 
            this.toolStripButton8.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton8.Image = global::EWPEditor.Plugin.Properties.Resources.Webdev_site_map;
            this.toolStripButton8.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.toolStripButton8.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton8.Name = "toolStripButton8";
            this.toolStripButton8.Size = new System.Drawing.Size(30, 30);
            this.toolStripButton8.Text = "新建文件夹";
            this.toolStripButton8.ToolTipText = "新建文件夹";
            this.toolStripButton8.Click += new System.EventHandler(this.ToolStripButton8_Click);
            // 
            // toolStripButton2
            // 
            this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton2.Image = global::EWPEditor.Plugin.Properties.Resources.Webdev_file;
            this.toolStripButton2.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Size = new System.Drawing.Size(30, 30);
            this.toolStripButton2.Text = "上传文件";
            this.toolStripButton2.ToolTipText = "上传文件";
            this.toolStripButton2.Click += new System.EventHandler(this.ToolStripButton2_Click);
            // 
            // toolStripSplitButton3
            // 
            this.toolStripSplitButton3.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
            this.toolStripSplitButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripSplitButton3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.手册ToolStripMenuItem,
            this.关于ToolStripMenuItem});
            this.toolStripSplitButton3.Image = global::EWPEditor.Plugin.Properties.Resources.Webdev_help;
            this.toolStripSplitButton3.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.toolStripSplitButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripSplitButton3.Name = "toolStripSplitButton3";
            this.toolStripSplitButton3.Size = new System.Drawing.Size(45, 30);
            this.toolStripSplitButton3.Text = "帮助";
            
            // 
            // 手册ToolStripMenuItem
            // 
            this.手册ToolStripMenuItem.Name = "手册ToolStripMenuItem";
            this.手册ToolStripMenuItem.Size = new System.Drawing.Size(130, 28);
            this.手册ToolStripMenuItem.Text = "手册";
            this.手册ToolStripMenuItem.Click += new System.EventHandler(Help_Click);
            // 
            // 关于ToolStripMenuItem
            // 
            this.关于ToolStripMenuItem.Name = "关于ToolStripMenuItem";
            this.关于ToolStripMenuItem.Size = new System.Drawing.Size(130, 28);
            this.关于ToolStripMenuItem.Text = "关于";
            this.关于ToolStripMenuItem.Click += new System.EventHandler(关于ToolStripMenuItem_Click);
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Font = new System.Drawing.Font("Microsoft YaHei", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.打开ToolStripMenuItem,
            this.编辑ToolStripMenuItem,
            this.导入本地内容ToolStripMenuItem,
            this.收藏选中内容ToolStripMenuItem,
            this.toolStripSeparator1,
            this.插入选中内容ToolStripMenuItem,
            this.删除选中内容ToolStripMenuItem});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(189, 178);
            this.contextMenuStrip1.VisibleChanged += new System.EventHandler(this.ContextMenuStrip1_VisibleChanged);
            // 
            // 打开ToolStripMenuItem
            // 
            this.打开ToolStripMenuItem.Name = "打开ToolStripMenuItem";
            this.打开ToolStripMenuItem.Size = new System.Drawing.Size(188, 28);
            this.打开ToolStripMenuItem.Text = "打开";
            this.打开ToolStripMenuItem.Click += new System.EventHandler(this.打开ToolStripMenuItem_Click);
            // 
            // 编辑ToolStripMenuItem
            // 
            this.编辑ToolStripMenuItem.Name = "编辑ToolStripMenuItem";
            this.编辑ToolStripMenuItem.Size = new System.Drawing.Size(188, 28);
            this.编辑ToolStripMenuItem.Text = "编辑";
            this.编辑ToolStripMenuItem.Click += new System.EventHandler(this.编辑ToolStripMenuItem_Click);
            // 
            // 导入本地内容ToolStripMenuItem
            // 
            this.导入本地内容ToolStripMenuItem.Name = "导入本地内容ToolStripMenuItem";
            this.导入本地内容ToolStripMenuItem.Size = new System.Drawing.Size(188, 28);
            this.导入本地内容ToolStripMenuItem.Text = "导入本地内容";
            this.导入本地内容ToolStripMenuItem.Click += new System.EventHandler(this.导入本地内容ToolStripMenuItem_Click);
            // 
            // 收藏选中内容ToolStripMenuItem
            // 
            this.收藏选中内容ToolStripMenuItem.Name = "收藏选中内容ToolStripMenuItem";
            this.收藏选中内容ToolStripMenuItem.Size = new System.Drawing.Size(188, 28);
            this.收藏选中内容ToolStripMenuItem.Text = "收藏选中内容";
            this.收藏选中内容ToolStripMenuItem.Click += new System.EventHandler(this.收藏选中内容ToolStripMenuItem_Click);
            // 
            // toolStripSeparator1
            // 
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(185, 6);
            // 
            // 插入选中内容ToolStripMenuItem
            // 
            this.插入选中内容ToolStripMenuItem.Name = "插入选中内容ToolStripMenuItem";
            this.插入选中内容ToolStripMenuItem.Size = new System.Drawing.Size(188, 28);
            this.插入选中内容ToolStripMenuItem.Text = "插入选中内容";
            this.插入选中内容ToolStripMenuItem.Click += new System.EventHandler(this.插入选中内容ToolStripMenuItem_Click);
            // 
            // 删除选中内容ToolStripMenuItem
            // 
            this.删除选中内容ToolStripMenuItem.Name = "删除选中内容ToolStripMenuItem";
            this.删除选中内容ToolStripMenuItem.Size = new System.Drawing.Size(188, 28);
            this.删除选中内容ToolStripMenuItem.Text = "删除选中内容";
            this.删除选中内容ToolStripMenuItem.Click += new System.EventHandler(this.删除选中内容ToolStripMenuItem_Click);
            // 
            // imageList1
            // 
            this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            this.imageList1.ImageSize = new System.Drawing.Size(24, 24);
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
            // 
            // 导出文档ToolStripMenuItem
            // 
            this.导出文档ToolStripMenuItem.Name = "导出文档ToolStripMenuItem";
            this.导出文档ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
            this.导出文档ToolStripMenuItem.Text = "导出文档";
            // 
            // openFileDialog1
            // 
            this.openFileDialog1.FileName = "openFileDialog1";
            // 
            // panel1
            // 
            this.panel1.AutoSize = true;
            this.panel1.Controls.Add(this.listView1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 93);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(210, 409);
            this.panel1.TabIndex = 3;
            // 
            // listView1
            // 
            this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader1});
            this.listView1.ContextMenuStrip = this.contextMenuStrip1;
            this.listView1.Font = new System.Drawing.Font("Microsoft YaHei", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.listView1.GridLines = true;
            this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
            this.listView1.HideSelection = false;
            this.listView1.LargeImageList = this.imageList1;
            this.listView1.Location = new System.Drawing.Point(0, 0);
            this.listView1.Margin = new System.Windows.Forms.Padding(4);
            this.listView1.Name = "listView1";
            this.listView1.OwnerDraw = true;
            this.listView1.Size = new System.Drawing.Size(210, 409);
            this.listView1.SmallImageList = this.imageList1;
            this.listView1.TabIndex = 4;
            this.listView1.UseCompatibleStateImageBehavior = false;
            this.listView1.View = System.Windows.Forms.View.Details;
            this.listView1.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.listView1_DrawItem);
            this.listView1.DoubleClick += new System.EventHandler(this.ListView1_DoubleClick);
            this.listView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ListView1_MouseClick);
            this.listView1.Resize += new System.EventHandler(this.listView1_Resize);
            // 
            // columnHeader1
            // 
            this.columnHeader1.Text = "";
            this.columnHeader1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.columnHeader1.Width = 210;
            // 
            // toolStripTextBox1
            // 
            this.toolStripTextBox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.toolStripTextBox1.Name = "toolStripTextBox1";
            this.toolStripTextBox1.Size = new System.Drawing.Size(206, 30);
            this.toolStripTextBox1.Enter += new System.EventHandler(this.ToolStripTextBox1_Enter);
            this.toolStripTextBox1.Leave += new System.EventHandler(this.ToolStripTextBox1_Leave);
            this.toolStripTextBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ToolStripTextBox1_KeyUp);
            this.toolStripTextBox1.TextChanged += new System.EventHandler(this.ToolStripTextBox1_TextChanged);
            // 
            // toolStripProgressBar1
            // 
            this.toolStripProgressBar1.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.toolStripProgressBar1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(195)))), ((int)(((byte)(230)))));
            this.toolStripProgressBar1.Name = "toolStripProgressBar1";
            this.toolStripProgressBar1.Size = new System.Drawing.Size(206, 22);
            this.toolStripProgressBar1.VisibleChanged += new System.EventHandler(this.ToolStripProgressBar1_VisibleChanged);
            // 
            // toolStripLabel1
            // 
            this.toolStripLabel1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
            this.toolStripLabel1.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.toolStripLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(195)))), ((int)(((byte)(230)))));
            this.toolStripLabel1.Name = "toolStripLabel1";
            this.toolStripLabel1.Size = new System.Drawing.Size(208, 0);
            // 
            // toolStrip2
            // 
            this.toolStrip2.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
            this.toolStrip2.ImageScalingSize = new System.Drawing.Size(24, 24);
            this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripTextBox1,
            this.toolStripProgressBar1,
            this.toolStripLabel1});
            this.toolStrip2.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
            this.toolStrip2.Location = new System.Drawing.Point(0, 33);
            this.toolStrip2.Name = "toolStrip2";
            this.toolStrip2.Size = new System.Drawing.Size(210, 60);
            this.toolStrip2.TabIndex = 2;
            this.toolStrip2.Text = "toolStrip2";
            // 
            // MainPane
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 23F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.toolStrip2);
            this.Controls.Add(this.toolStrip1);
            this.Font = new System.Drawing.Font("Microsoft YaHei", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.Margin = new System.Windows.Forms.Padding(2);
            this.Name = "MainPane";
            this.Size = new System.Drawing.Size(210, 502);
            this.Load += new System.EventHandler(this.MainPane_Load);
            this.Resize += new System.EventHandler(this.MainPane_Resize);
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.toolStrip2.ResumeLayout(false);
            this.toolStrip2.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
    
        }
    
    
        #endregion
    
        private ToolStrip toolStrip1;
        private ToolStripButton toolStripButton1;
        private ToolStripButton toolStripButton2;
        private ToolStripButton toolStripButton4;
        private ToolStripSplitButton toolStripSplitButton3;
        private ToolStripMenuItem 手册ToolStripMenuItem;
        private ToolStripMenuItem 关于ToolStripMenuItem;
        private ContextMenuStrip contextMenuStrip1;
        private ToolStripMenuItem 打开ToolStripMenuItem;
        public ImageList imageList1;
        private ToolStripMenuItem 导出文档ToolStripMenuItem;
        private ToolStripButton toolStripButton8;
        private ToolStripMenuItem 编辑ToolStripMenuItem;
        private ToolStripMenuItem 导入本地内容ToolStripMenuItem;
        private ToolStripMenuItem 收藏选中内容ToolStripMenuItem;
        private ToolStripSeparator toolStripSeparator1;
        private ToolStripMenuItem 插入选中内容ToolStripMenuItem;
        private ToolStripMenuItem 删除选中内容ToolStripMenuItem;
        private ToolStripSeparator toolStripSeparator3;
        private OpenFileDialog openFileDialog1;
        private ToolStripSeparator toolStripSeparator2;
        private ToolStripButton toolStripButton13;
        private Panel panel1;
        private ToolStripTextBox toolStripTextBox1;
        private ToolStripProgressBar toolStripProgressBar1;
        private ToolStripLabel toolStripLabel1;
        private ToolStrip toolStrip2;
        public DoubleBufferListView listView1;
        private ColumnHeader columnHeader1;
        private System.Windows.Forms.Timer DownloadingProgerssTimer;
     }

     }

个字符
` toolStripProgressBar1.Maximum = files.Count;

toolStripProgressBar1.Value = 0;
                toolStripProgressBar1.Visible = true;

                toolStripLabel1.Text =  "0%";
                toolStripLabel1.Visible = true;`
          </code></pre>


效果如下,listView 1的第一项将显示在toolStripProgressBar 1和toolStripLabel 1的位置
x1c 0d1x的数据

628mspwn

628mspwn1#

我试图通过复制你的设计器文件并删除事件处理程序来最小限度地重现你的问题。如果我禁用所有者绘制,事情似乎工作。根据你的帖子中提供的信息,这可能指向你的绘图代码中的问题(似乎没有显示)。
显示进度条和标签会导致列表视图移动。当发生这种情况时,它可能会像刷新列表视图一样简单,这样您就可以使用当前Graphics上下文绘制到新的边界。


的数据

public MainPane()
{
    InitializeComponent();
    listView1.OwnerDraw = false;

    toolStripProgressBar1.Visible = false;
    toolStripLabel1.Visible = false;
    listView1.BackColor = Color.Azure;
    listView1.View = View.Details;

    for (int i = 0; i < 5; i++)
    {
        ListViewItem item = new ListViewItem($"Hello {i + 1}");
        listView1.Items.Add(item);
    }
    listView1.Refresh();

    toolStripTextBox1.TextChanged += (sender, e) =>
    {
        toolStripProgressBar1.Visible = 
        toolStripLabel1.Visible = !string.IsNullOrWhiteSpace(toolStripTextBox1.Text);
        toolStripProgressBar1.Value = 50; 
        toolStripLabel1.Text = "Visible";

        BeginInvoke(()=>    
        {
        toolStripTextBox1.Focus();
        });
    };
}

字符串

相关问题