C# panel 滚动条滚动时闪屏问题

shuaikaiyuan 2015-03-23 12:02:55

正常情况的样子

当panel上滑动滚动条的时候 屏幕变花了。已开启双缓存
...全文
1052 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜鸟的挣扎 2017-03-09
  • 打赏
  • 举报
回复
我遇过类似的问题,当时解决的方法是:定义一个List类,panel上的信息全存放到list里面。 触发时把界面全清空,结束时再重新从List取出信息加载回去 不知道这个方法对楼主管用不
Gary9529 2015-04-07
  • 打赏
  • 举报
回复
是不是使用的 PictureBox 的 Image 属性? 最好使用 PictureBox 的 ImageLocation 属性指定显示的图片。 设置所有背景为非透明,设置所有背景图片为空。
shuaikaiyuan 2015-04-06
  • 打赏
  • 举报
回复
引用 17 楼 BenBenBears 的回复:
问题出在UStation控件身上,Paint事件中什么代码?
没有重写Paint事件
BenBenBears 2015-03-25
  • 打赏
  • 举报
回复
问题出在UStation控件身上,Paint事件中什么代码?
本拉灯 2015-03-23
  • 打赏
  • 举报
回复
引用 15 楼 shuaikaiyuan 的回复:
[quote=引用 12 楼 wyd1520 的回复:] UStation 这里面把所有背影是透明的设成排透明。。
--------------------------------------------------------------------------------------- 图片里的有局部透明没有影响吧[/quote] 最好图片里都不要透明。透明了,都会刷新的。
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
引用 12 楼 wyd1520 的回复:
UStation 这里面把所有背影是透明的设成排透明。。
--------------------------------------------------------------------------------------- 图片里的有局部透明没有影响吧
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
引用 12 楼 wyd1520 的回复:
UStation 这里面把所有背影是透明的设成排透明。。
------------------------------------------------------------------------------------ 设的是非透明的
qq_21389129 2015-03-23
  • 打赏
  • 举报
回复
也开起了  图中是2个panel   一个全屏的  一个居中带滚动条的
本拉灯 2015-03-23
  • 打赏
  • 举报
回复
UStation 这里面把所有背影是透明的设成排透明。。
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AGaugeApp
{
    public partial class Form4 : Form
    {
        private int[] x = { 21, 212, 403, 594, 785, 976 };
        private int y = 0;
        protected Label[] La_txt;
        protected UStation[][] Station;
         int[] SCONUT = { 16, 15, 12, 14, 14, 16, 18 };
        const int COUNT=7;
        public Form4()
        {
            InitializeComponent();
            this.BackColor = System.Drawing.Color.FromArgb(53, 53, 53);
            panel2.VerticalScroll.SmallChange = 10;
            InitStation();
        }

        protected void InitStation()
        {
            La_txt = new Label[COUNT];
            Station = new UStation[COUNT][];
            for (int i = 0; i < COUNT; i++)
            {
                La_txt[i]=new Label();
                La_txt[i].Font = new System.Drawing.Font("楷体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                La_txt[i].ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
                La_txt[i].Location = new System.Drawing.Point(0, y);
                La_txt[i].Size = new System.Drawing.Size(106, 29);
                La_txt[i].Text = "前桥线";
                y += La_txt[i].Height + 3;
                Station[i] = new UStation[SCONUT[i]];
                this.panel2.Controls.Add(La_txt[i]);
                for (int j = 0; j < SCONUT[i]; j++)
                {
                    Station[i][j] = new UStation();
                    Station[i][j].Location = new System.Drawing.Point(x[j % 6], y);
                    if (j % 6 == 5)
                    {
                        y += 70 + 3;
                    }
                    if (j % 6 == 3)
                    {
                        Station[i][j].SetRun();
                    }
                    this.panel2.Controls.Add(Station[i][j]);
                }
                if (SCONUT[i] % 6 != 0)
                {
                    y += 70 + 3;
                }

            }
        }
    }
}
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
窗体代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace AGaugeApp { public partial class Form4 : Form { private int[] x = { 21, 212, 403, 594, 785, 976 }; private int y = 0; protected Label[] La_txt; protected UStation[][] Station; int[] SCONUT = { 16, 15, 12, 14, 14, 16, 18 }; const int COUNT=7; public Form4() { InitializeComponent(); this.BackColor = System.Drawing.Color.FromArgb(53, 53, 53); panel2.VerticalScroll.SmallChange = 10; InitStation(); } protected void InitStation() { La_txt = new Label[COUNT]; Station = new UStation[COUNT][]; for (int i = 0; i < COUNT; i++) { La_txt[i]=new Label(); La_txt[i].Font = new System.Drawing.Font("楷体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); La_txt[i].ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))); La_txt[i].Location = new System.Drawing.Point(0, y); La_txt[i].Size = new System.Drawing.Size(106, 29); La_txt[i].Text = "前桥线"; y += La_txt[i].Height + 3; Station[i] = new UStation[SCONUT[i]]; this.panel2.Controls.Add(La_txt[i]); for (int j = 0; j < SCONUT[i]; j++) { Station[i][j] = new UStation(); Station[i][j].Location = new System.Drawing.Point(x[j % 6], y); if (j % 6 == 5) { y += 70 + 3; } if (j % 6 == 3) { Station[i][j].SetRun(); } this.panel2.Controls.Add(Station[i][j]); } if (SCONUT[i] % 6 != 0) { y += 70 + 3; } } } } } 没做什么特别的操作就是,量有点大。 UStation控件是自己写的,里面就一个Picture和几个Label,还开起来双缓存 this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); this.UpdateStyles();
本拉灯 2015-03-23
  • 打赏
  • 举报
回复
你还做了啥了?如果只是一些控件是不会这样的。
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
引用 7 楼 wyd1520 的回复:
[quote=引用 6 楼 shuaikaiyuan 的回复:]
[quote=引用 5 楼 wyd1520 的回复:]


大概知道啥问题了。
你不要用那种透明的图片。只能用透明的。
还有PictureBox的背景也不要设成透明的。因为透明了,UI每变一次,都要整体刷新一下。。。

--------------------------------------------------------------------------------------------------------------------------------------------
就是说panel 和 PictureBox 背景颜色设为指定颜色 是么?[/quote]
是地。你指定成控件默认的色这样就不会刷了。[/quote]
-----------------------------------------------------------------------------------------------------------------------------------------
我已经改成默认颜色了 ,好了点,但还是这样
本拉灯 2015-03-23
  • 打赏
  • 举报
回复
引用 6 楼 shuaikaiyuan 的回复:
[quote=引用 5 楼 wyd1520 的回复:] 大概知道啥问题了。 你不要用那种透明的图片。只能用透明的。 还有PictureBox的背景也不要设成透明的。因为透明了,UI每变一次,都要整体刷新一下。。。
-------------------------------------------------------------------------------------------------------------------------------------------- 就是说panel 和 PictureBox 背景颜色设为指定颜色 是么?[/quote] 是地。你指定成控件默认的色这样就不会刷了。
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
引用 5 楼 wyd1520 的回复:
大概知道啥问题了。 你不要用那种透明的图片。只能用透明的。 还有PictureBox的背景也不要设成透明的。因为透明了,UI每变一次,都要整体刷新一下。。。
-------------------------------------------------------------------------------------------------------------------------------------------- 就是说panel 和 PictureBox 背景颜色设为指定颜色 是么?
本拉灯 2015-03-23
  • 打赏
  • 举报
回复
大概知道啥问题了。 你不要用那种透明的图片。只能用透明的。 还有PictureBox的背景也不要设成透明的。因为透明了,UI每变一次,都要整体刷新一下。。。
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
引用 2 楼 shuaikaiyuan 的回复:
也开起了 图中是2个panel 一个全屏的 一个居中带滚动条的
----------------------------------------------------------------------------------------------- 是图片啊 PictureBox
本拉灯 2015-03-23
  • 打赏
  • 举报
回复
那些显示器是GDI+画的?还是Picture控件?
shuaikaiyuan 2015-03-23
  • 打赏
  • 举报
回复
也开起了 图中是2个panel 一个全屏的 一个居中带滚动条的
luxuewei5214 2015-03-23
  • 打赏
  • 举报
回复
form是不是也得开启双缓存?

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧