suspendlayoutc#怎么关闭messagebox

suspendlayout  时间:2021-06-05  阅读:()

C# 界面初始化时listview需要加载大量数据,求教提高速度的方法!!!

首先,一个列表里面有7万格项目是不合理的,因为你将没有办法通过拖动滚动条来准确定位,毕竟7万条记录的list滚动条得多小啊 其次,如果非要显示的话,建议使用异步填充,先组织好一批数据,然后填充这一批,期间UI线程还是可以相应的,这样虽然速度没有提升,但是用户体验会好一些 再次,如果要求必须一次填充完成的话,在开始填充时使用SuspendLayout(),挂起更新画面项目,然后在填充完以后ResumeLayout(true)恢复更新画面,并将前面挂起的画面更新恢复。

这样可以一定程度上节省更新的时间。

iewSample.SuspendLayout(); this.LoadListData(); iewSample.ResumeLayout(true); Ps: IsPostback是BS系统上面的,在你的Winform上没有意义。

金山词霸采用的是我说的第二种方案配合第三种方案,只加载一小部分,在你拖动滚动条的时候填充当前滚动条指定的那一段。

相当于分页。

上下滚动条vScrollBar怎么使用呀?我把滚动条放在PictureBox 里面,怎么让它们里面的内容发生滚动呢?

单就VScrollBar控件的使用来说,楼主可以参考下面的代码,但这可能并不能解决你的问题因为这还需要做很多其它的工作。

不过我还是愿意帮你解决问题而写了如下的一段代码,这是一个控件,可以放到窗体上运行后查看滚动条的效果,但或许有人能给楼主一更为完美的解决方案: C# code public partial class UserControl1 : UserControl { [StructLayout(LayoutKind.Sequential)] internal struct RECT { public int left; public ; public int right; public int bottom; public RECT(int left, , int right, int bottom) { this.left = left; =; this.right = right; this.bottom = bottom; } } [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] private static extern bool ScrollWindow(IntPtr hWnd, int nXAmount, int nYAmount, ref RECT rectScrollRegion, ref RECT rectClip); private System.Windows.Forms.VScrollBar vScrollBar1; private int m_Top; public UserControl1() { this.InitializeComponent(); this.SetStyle(ControlStyles.ResizeRedraw, true); m_Top = 0; this.vScrollBar1.Scroll += new ScrollEventHandler(vScrollBar1_Scroll); } private void InitializeComponent() { this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.SuspendLayout(); // // vScrollBar1 // this.vScrollBar1.Location = new System.Drawing.Point(275, 57); this.vScrollBar1.Name = "vScrollBar1"; this.vScrollBar1.Size = new System.Drawing.Size(17, 80); this.vScrollBar1.TabIndex = 0; // // UserControl1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.vScrollBar1); this.Name = "UserControl1"; this.Size = new System.Drawing.Size(304, 174); this.ResumeLayout(false); } private void setScrollBar() { this.vScrollBar1.Top = 0; this.vScrollBar1.Left = this.Width - this.vScrollBar1.Width; this.vScrollBar1.Height = this.Height; this.vScrollBar1.Maximum = 1000 - this.Height; this.vScrollBar1.LargeChange = this.Height; this.vScrollBar1.Maximum += this.vScrollBar1.LargeChange + 1; this.m_Top = this.vScrollBar1.Value; } private RECT getBodyRect() { int left = 0; = 0; int width = this.Width-this.vScrollBar1.Width; int height = this.Height; RECT rect = new RECT(left,, left + width,+height); return rect; } void vScrollBar1_Scroll(object sender, ScrollEventArgs e) { RECT vSRect = this.getBodyRect(); ScrollWindow(this.Handle, 0, -(e.NewValue - m_Top), ref vSRect, ref vSRect); m_Top = e.NewValue; } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle rect = new Rectangle(0, -m_Top, this.Width - this.vScrollBar1.Width, 1000); e.Graphics.DrawEllipse(SystemPens.ControlDark, rect); } protected override void OnLayout(LayoutEventArgs e) { if (e.AffectedControl == this) { this.setScrollBar(); } base.OnLayout(e); } } 百度把缩进都给屏蔽了。

你将就看吧,或者复制到ide里格式化一下吧

c# 子窗口怎样添加控件?

DataGridView dg = new DataGridView(); this.Controls.Add(dg); 在窗体中的位置用dg.Left=100和dg.Top=100;来调整

c#怎么关闭messagebox

using?System; using?System.Drawing; using?System.Collections; using?System.ComponentModel; using?System.Windows.Forms; using?System.Data; using?System.Runtime.InteropServices; namespace?MyTest ...{ ????/**////?<summary> ????///?Form1?的摘要说明。

????///?</summary> ????public?class?Form1?:?System.Windows.Forms.Form ????...{ ????????private?System.Windows.Forms.Button?button1; ????????/**////?<summary> ????????///?必需的设计器变量。

????????///?</summary> ????????private?ponents?=?null; ????????public?Form1() ????????...{ ????????????// ????????????//?Windows?窗体设计器支持所必需的 ????????????// ????????????InitializeComponent(); ????????????// ????????????//?TODO:?在?InitializeComponent?调用后添加任何构造函数代码 ????????????// ????????} ????????/**////?<summary> ????????///?清理所有正在使用的资源。

????????///?</summary> ????????protected?override?void?Dispose(?bool?disposing?) ????????...{ ????????????if(?disposing?) ????????????...{ ????????????????if?ponents?!=?null)? ????????????????...{ ???????????????????ponents.Dispose(); ????????????????} ????????????} ????????????base.Dispose(?disposing?); ????????} ????????Windows?窗体设计器生成的代码#region?Windows?窗体设计器生成的代码 ????????/**////?<summary> ????????///?设计器支持所需的方法?-?不要使用代码编辑器修改 ????????///?此方法的内容。

????????///?</summary> ????????private?void?InitializeComponent() ????????...{ ????????????this.button1?=?new?System.Windows.Forms.Button(); ????????????this.SuspendLayout(); ????????????//? ????????????//?button1 ????????????//? ????????????this.button1.Location?=?new?System.Drawing.Point(176,?48); ????????????this.button1.Name?=?"button1"; ????????????this.button1.Size?=?new?System.Drawing.Size(96,?24); ????????????this.button1.TabIndex?=?0; ????????????this.button1.Text?=?"button1"; ????????????this.button1.Click?+=?new?System.EventHandler(this.button1_Click); ????????????//? ????????????//?Form1 ????????????//? ????????????this.AutoScaleBaseSize?=?new?System.Drawing.Size(6,?14); ????????????this.ClientSize?=?new?System.Drawing.Size(292,?266); ????????????this.Controls.Add(this.button1); ????????????this.Name?=?"Form1"; ????????????this.Text?=?"Form1"; ????????????this.ResumeLayout(false); ????????} ????????#endregion ????????/**////?<summary> ????????///?应用程序的主入口点。

????????///?</summary> ????????[STAThread] ????????static?void?Main()? ????????...{ ????????????Application.Run(new?Form1()); ????????} ????????private?void?button1_Click(object?sender,?System.EventArgs?e) ????????...{ ????????????StartKiller(); ????????????MessageBox.Show("这里是MessageBox弹出的内容","MessageBox"); ????????????MessageBox.Show("这里是跟随运行的窗口","窗口"); ????????} ????????private?void?StartKiller() ????????...{ ????????????Timer?timer?=?new?Timer(); ????????????timer.Interval?=?10000;????//10秒启动 ????????????timer.Tick?+=?new?EventHandler(Timer_Tick); ????????????timer.Start(); ????????} ????????private?void?Timer_Tick(object?sender,?EventArgs?e) ????????...{ ????????????KillMessageBox(); ????????????//停止计时器 ????????????((Timer)sender)(); ????????} ????????private?void?KillMessageBox() ????????...{ ????????????//查找MessageBox的弹出窗口,注意对应标题 ????????????IntPtr?ptr?=?FindWindow(null,"MessageBox"); ????????????if(ptr?!=?IntPtr.Zero) ????????????...{ ????????????????//查找到窗口则关闭 ????????????????PostMessage(ptr,WM_CLOSE,IntPtr.Zero,IntPtr.Zero); ????????????} ????????} ????????[DllImport("user32.dll",?EntryPoint?=?"FindWindow",?CharSet=CharSet.Auto)] ????????private?extern?static?IntPtr?FindWindow(string?lpClassName,?string?lpWindowName); ????????[DllImport("user32.dll",?CharSet=CharSet.Auto)] ????????public?static?extern?int?PostMessage(IntPtr?hWnd,?int?msg,?IntPtr?wParam,?IntPtr?lParam); ????????public?const?int?WM_CLOSE?=?0x10; ????}

百星数据(60元/月,600元/年)日本/韩国/香港cn2 gia云服务器,2核2G/40G/5M带宽

百星数据(baixidc),2012年开始运作至今,主要提供境外自营云服务器和独立服务器出租业务,根据网络线路的不同划分为:美国cera 9929、美国cn2 gia、香港cn2 gia、韩国cn2 gia、日本cn2 gia等云服务器及物理服务器业务。目前,百星数据 推出的日本、韩国、香港cn2 gia云服务器,2核2G/40G/5M带宽低至60元/月,600元/年。百星数据优惠码:优惠码:30...

HostYun 新增可选洛杉矶/日本机房 全场9折月付19.8元起

关于HostYun主机商在之前也有几次分享,这个前身是我们可能熟悉的小众的HostShare商家,主要就是提供廉价主机,那时候官方还声称选择这个品牌的机器不要用于正式生产项目,如今这个品牌重新转变成Hostyun。目前提供的VPS主机包括KVM和XEN架构,数据中心可选日本、韩国、香港和美国的多个地区机房,电信双程CN2 GIA线路,香港和日本机房,均为国内直连线路,访问质量不错。今天和大家分享下...

织梦DEDECMS即将授权收费和维权模式 站长应对的几个方法

这两天在站长群里看到不少有使用DEDECMS织梦程序的朋友比较着急,因为前两天有看到来自DEDECMS,我们熟悉的织梦程序官方发布的公告,将会在10月25日开始全面商业用途的使用DEDECMS内容管理程序的会采用授权收费模式,如果我们有在个人或者企业商业用途的,需要联系且得到授权才可以使用,否则后面会通过维权的方式。对于这个事情,我们可能有些站长经历过,比如字体、图片的版权。以及有一些国内的CMS...

suspendlayout为你推荐
jsmJSM们有用过什么化妆品能使鼻子和脸部立体泛珍珠白的感觉的产品吗?心水分享,谢谢宝应中学宝应初级中学有哪些chrome系统谷歌Chrome OS可以用来做什么?扫图高清扫图是什么意思,在很多的贴吧里,都有提到一些高清扫图,是自己照杂志上的图片,然后自己再修一下吗小四号字Excel小四号字等于几号字数据统计分析表怎样建立数据透视表和数据分析表?asp大马一句话木马中的大马和小马的作用各是什么?微软操作系统下载怎么下载官方win10 64位镜像系统微软操作系统下载微软的系统到哪下载文本框透明word里文本框怎么透明?
手机域名注册 域名查询系统 互联网域名管理办法 堪萨斯服务器 dreamhost 网站保姆 ibox官网 bgp双线 股票老左 网络空间租赁 网游服务器 如何注册阿里云邮箱 360云服务 监控服务器 阵亡将士纪念日 服务器托管价格 石家庄服务器 web服务器 hosts文件 低价 更多