码迷,mamicode.com
首页 > 其他好文 > 详细

dev listbox使用

时间:2018-09-28 12:37:54      阅读:394      评论:0      收藏:0      [点我收藏+]

标签:var   cli   csharp   data   dev   mil   item   arp   box   

private void Init()
{
List<Funcation> data = new List<Funcation>();
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

技术分享图片

 

dev listbox使用

标签:var   cli   csharp   data   dev   mil   item   arp   box   

原文地址:https://www.cnblogs.com/shuaimeng/p/9717429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!