dev listbox使用
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