C# - 在表单上格式化 ListView 控件的常用方法?

标签 c# winforms listview

在 C# Winform 应用程序 (3.5) 中,有许多表单,每个表单都有不同的 ListView 控件。虽然每个 ListView 控件使用不同的数据集,但每个控件的基本格式保持不变。

基本格式采用以下形式:

  /* appearance */
  this.lstA.View = View.Details;
  this.lstA.AllowColumnReorder = true;
  this.lstA.CheckBoxes = false;
  this.lstA.FullRowSelect = true;
  this.lstA.GridLines = false;
  this.lstA.Sorting = SortOrder.Ascending;

我想做的是创建一个可用于设置 ListView 初始格式的类。

如何将 ListView (通过引用?)传递给类,以便可以设置外观属性?

最佳答案

也许您可以将 ListView 子类化,然后设置您的默认功能,然后在您现在使用普通 ListView 的任何地方使用您的子类 ListView。

关于C# - 在表单上格式化 ListView 控件的常用方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2593515/

相关文章:

c# - asp.net MVC自定义Authorize属性,传递参数和方法细节

c# - 如何在 C# 中将字符串值从一种形式传递到另一种形式的加载事件

c# - 使用 DataGridView 的 WinForms 数据绑定(bind)

.net - PowerShell .NET 模仿 Windows 树节点的默认复选框行为

WPF:是否可以创建多个 ListView.View 模板并在运行时动态选择一个?

c# - 从 DataTemplate UWP 绑定(bind) UserControl DP

c# - 将字符串初始化为 ""或 ""之间的区别 .ToString() - 我应该使用哪个?

android - RelativeLayout 中的 TextView 与 ImageView 重叠

android - 如何在 ListView 中的每个第 n 个位置显示一个 AdView

c# - 放一个类名=命名空间,在使用