常见winform处理:
1. //不显示窗体标题栏
this.FormBorderStyle=FormBorderStyle.None;
//任务栏不显示
this.ShowInTaskbar=false;
2. 自定义Form问题
获得包含任务栏的屏幕大小
var h = Screen.PrimaryScreen.Bounds.Height;
var w = Screen.PrimaryScreen.Bounds.Width;
不包含任务栏大小:
var h = SystemInformation.WorkingArea.Height;
var w = SystemInformation.WorkingArea.Width;
默认,自定义Form最大化把任务栏覆盖掉,可以如下设置,显示任务栏
this.MaximizedBounds =Screen.PrimaryScreen.WorkingArea;
this.WindowState=FormWindowState.Maximized;
3. winform 拖动 datagridview,闪烁问题,可以在绑定数据源后面添加如下代码规避闪烁:
Type type = DataGridView.GetType();
PropertyInfo pi = type.GetProperty("DoubleBuffered",BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(DataGridView, true, null);
记录一下,以备遗忘。
本文介绍了WinForm开发中的一些实用技巧,包括如何隐藏窗体标题栏、调整窗体大小以适应不同屏幕并保持任务栏可见、解决DataGridView拖动时的闪烁问题等。这些技巧有助于提升应用程序的用户体验。
1613

被折叠的 条评论
为什么被折叠?



