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; ????}

MechanicWeb免费DirectAdmin/异地备份

MechanicWeb怎么样?MechanicWeb好不好?MechanicWeb成立于2008年,目前在美国洛杉矶、凤凰城、达拉斯、迈阿密、北卡、纽约、英国、卢森堡、德国、加拿大、新加坡有11个数据中心,主营全托管型虚拟主机、VPS主机、半专用服务器和独立服务器业务。MechanicWeb只做高端的托管vps,这次MechanicWeb上新Xeon W-1290P处理器套餐,基准3.7GHz最高...

PQS彼得巧 年中低至38折提供台湾彰化HiNet线路VPS主机 200M带宽

在六月初的时候有介绍过一次来自中国台湾的PQS彼得巧商家(在这里)。商家的特点是有提供台湾彰化HiNet线路VPS主机,起步带宽200M,从带宽速率看是不错的,不过价格也比较贵原价需要300多一个月,是不是很贵?当然懂的人可能会有需要。这次年中促销期间,商家也有提供一定的优惠。比如月付七折,年付达到38折,不过年付价格确实总价格比较高的。第一、商家优惠活动年付三八折优惠:PQS2021-618-C...

旅途云(¥48 / 月),雅安高防4核4G、洛阳BGP 2核2G

公司成立于2007年,是国内领先的互联网业务平台服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前,旅途云公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、双线高防、香港等优质的IDC资源。点击进入:旅途云官方网商家LOGO优惠方案:CPU内存硬盘带宽/流量/防御...

suspendlayout为你推荐
视频压缩算法MP4视频压缩,比特率如何计算。orphanremovalorphan是什么意思腾讯汽车网可以了解汽车知识的权威网站大概有哪些网络电话永久免费打有没有永久免费打电话的网络电话啊?币众筹众筹平台开发哪家好微信智能机器人有一个人加我微信,他说他自己是图灵机器人,我想问一下这是啥软件怎么可以自动回复微信?activitygroupAndroid中如何在ActivityGroup里面监听back按钮,使得可按要求实现哪个activity可返回,哪个不需要。。中信银行理财宝中信银行理财宝金卡怎样激活人脸识别解锁手机解锁的人脸识别怎么设置网络电话免费版有没有免费的网络电话?纯免费的
手机网站空间 西安服务器租用 中文国际域名 新加坡主机 台湾服务器 wavecom la域名 空间打开慢 国内加速器 eq2 京东商城0元抢购 100x100头像 怎样建立邮箱 网站木马检测工具 广州服务器 新世界服务器 无限流量 环聊 监控服务器 大化网 更多