dev listbox使用
阅读原文时间:2023年07月08日阅读:1

private void Init()
{
List data = new List();
data.Add(new Funcation() { FunctionName = "测试窗体", FunctionKey = "DevDemoList.frmedit" });
data.Add(new Funcation() { FunctionName = "RibbonForm窗体", FunctionKey = "DevDemoList.frmMain" });

lsbFunction.DataSource = data;
lsbFunction.DisplayMember = "FunctionName";
lsbFunction.ValueMember = "FunctionKey";
}

private void listBoxControl1_Click(object sender, EventArgs e)
{
var SelectRow = lsbFunction.GetItem(lsbFunction.SelectedIndex) as Funcation;
if (SelectRow != null)
AddDocument(SelectRow);
}

选中的样式

先设置属性

private void lsbFunction_DrawItem(object sender, ListBoxDrawItemEventArgs e)

{
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
e.Appearance.BackColor = Color.SkyBlue;
e.Appearance.ForeColor = Color.White;
}
}

设置行高 ItemHeight=26

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章