如何解决在C#Windows窗体ListView的列宽? [英] how to fix the column width of a listview in c# windows form?

查看:221
本文介绍了如何解决在C#Windows窗体ListView的列宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图我需要修复的列表视图的列宽,以便在运行时用户无法拖动columnheaders并调整其大小.....程序是什么?
我已经找遍了所有的属性,但没有人帮助我解决这个PBM ..
这是可能的,但GridView的它将如何可能在列表视图....

i have a listview i need to fix the column width of the listview so that at run time user cannot drag the columnheaders and resize it.....what is the procedure?? i have searched all the properties but none of them help me out to solve this pbm.. this is possible in gridview but how will it be possible in listview....

推荐答案

最简单的方法是使用 Col​​umnWidthChanging 事件:

The easiest way is to use ColumnWidthChanging event:

private void listView_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
    e.Cancel = true;
    e.NewWidth = listView.Columns[e.ColumnIndex].Width;
}

这篇关于如何解决在C#Windows窗体ListView的列宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆