当前位置:网站首页>The listview column in C automatically adapts to the perfect effect of scaling
The listview column in C automatically adapts to the perfect effect of scaling
2022-04-21 07:58:00 【Haihong AA】
I searched many ways on the Internet , Include width=-1、-2, The effect is not ideal . I found a way :
1: When the design , First, roughly adjust the size of each column ;

2: Write down the columns at startup width Proportion .

public class colSizes : List<double> { };
public colSizes[] grdSizes = new colSizes[3];
public DateTime dBegin = DateTime.Today;
loadSizes(grd_ing, ref grdSizes[0]);
loadSizes(grd_hege, ref grdSizes[1]);
loadSizes(grd_buhege, ref grdSizes[2]);
///
private void loadSizes(ListView grd, ref colSizes cs)
{ // Remember proportion
if (cs == null) cs = new colSizes();
cs.Clear();
double nAll = 0;
foreach (ColumnHeader itm in grd.Columns) nAll += itm.Width;
foreach (ColumnHeader itm in grd.Columns) cs.Add(itm.Width / nAll);
}

3:resize Reset the of each column in proportion width.

private void setAutoSize(ListView grd, colSizes cs)
{ // Auto fit width ,-1 Set the width according to the content ,-2 Set the width according to the title
if (cs == null) return;
for (int i = 0; i < Math.Min(cs.Count, grd.Columns.Count); i++)
grd.Columns[i].Width = (int)Math.Round(grd.ClientSize.Width * cs[i], 0);
}
private void FrmView_Resize(object sender, EventArgs e)
{
setAutoSize(grd_ing, grdSizes[0]);
setAutoSize(grd_hege, grdSizes[1]);
setAutoSize(grd_buhege, grdSizes[2]);
}

The effect is perfect , To scale
版权声明
本文为[Haihong AA]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210628208619.html
边栏推荐
- Virtual machine host Ping SSH campus network bridge net
- NAS选购参考对比
- go语言记录日志uber-go/zap/lumberjack的用法
- 【图像融合】基于拉普拉斯金字塔+小波变换实现图像融合含Matlab源码
- [image fusion] image fusion based on curvelet transform (evaluation index), including Matlab source code
- PHP determines whether it is the same month
- Why is the primary key matching setting in MySQL showing that I am wrong?
- 从零开始学习C语言日记——DAY27扫雷
- Dynamically generate three-level menu
- STM32系统和自定义bootloader的实现和应用
猜你喜欢

Valentina Studio Pro for Mac(mac数据库管理软件)

343. Find the product of decomposed integers and maximize integer break

Implementation and application of STM32 system and custom bootloader

Solution to red flag with @ Autowired annotation in idea

Leetcode title -- 386 Dictionary rank, DFS

Bluetooth Profile Specification之(AVRCP篇)5.1AVCTP的连接和释放

路由器设备选型参照天梯

2022-04-20: the small regiment goes to participate in the military training. The military training is coming to an end. The officer wants to divide n people in a row into m groups, and then ask each g

如何修改 Rancher Server 的 IP 地址

上古神器Vim
随机推荐
Post sqlmap injection method
联合类型和类型保护
云原生KubeSphere实战多租户系统实战
网关与分布式id
PHP infinite classification (recursive)
Postgre(pg)-SQL脚本记录
2022-04-20: the small regiment goes to participate in the military training. The military training is coming to an end. The officer wants to divide n people in a row into m groups, and then ask each g
2022G3锅炉水处理考试题库及答案
【2022DASCTF X SU】 三月春季挑战赛 web复现
注解功能补充
MySQL5. 7 installation and operation manual (centos7)
TypeScript函数泛型
Introduction to QT 5.12 actual combat
Supplément à la fonction d'annotation
torch中permute()函数用法补充内容(矩阵维度变化详细过程)
IIC bus design ① - IIC communication protocol
Laravel print SQL
《C#零基础入门之百识百例》(九十七)线程介绍 -- Thread类 -- 开启线程的几种方式
matlab画散点图
2022-4-20作业