问题描述
我想从 BrightIdeasSoftware (http://objectlistview.sourceforge.net/en/recipes.html) 获得有关 ObjectListView 组件的建议。
- 我使用 objectListView1_FormatRow 事件根据条件为行着色。问题是颜色只应用于新添加的行,而不是返回到现有的行。
private void objectListView1_FormatRow (object sender,FormatRowEventArgs e)
{
// fixes the color highlighting of the control if it matches the filter expression
// I just want to finish it somehow,so that in case of a filter change at runtime it is restored. When you sit on the filter,only things that are not back get dirty.
ProcessCDPPacket packet = (ProcessCDPPacket) e.Model;
if (! packet.IsCDPFiltered)
{
e.Item.BackColor = SystemColors.Info;
}
}
我的场景: 我有一个带有过滤器(正则表达式字符串)的输入字段,可以随时间变化。如果该行与过滤器匹配,则会突出显示。但是,如果用户更改过滤器,则不会更新突出显示。
有没有办法根据新标准恢复和着色 ObjectListView 中的现有行(对象)?有没有办法不突出显示所有颜色?我尝试了 ResetBackColor、ResetForeColor 方法,但没有成功。
private void objectListView1_CellRightClick (object sender,CellRightClickEventArgs e)
{
if (e.Model! = null)
{
ProcessCDPPacket packet = (ProcessCDPPacket) e.Model;
ToolStripMenuItem mi = new ToolStripMenuItem (String.Format ("Export package contents {0}",packet.deviceidParams.deviceid));
mi.Tag = packet;
mi.Click + = attemptToolStripMenuItem_Click;
contextMenuStrip1.Items.Clear ();
contextMenuStrip1.Items.Add (mi);
// assign the menu to my objectlistview
e.MenuStrip = this.contextMenuStrip1;
}
}
private void attemptToolStripMenuItem_Click (object sender,EventArgs e)
{
ProcessCDPPacket packet = (ProcessCDPPacket) ((ToolStripMenuItem) sender).Tag;
MessageBox.Show(hex);
}
- 是否可以只显示垂直网格线?
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)