c# navigationPane、navigationPage设置可选择列显示
实现效果https://i-blog.csdnimg.cn/direct/9ed652c196d04b61a00960529397e0c5.png
https://i-blog.csdnimg.cn/direct/6e019b65b58f4472a29263bcefe6f276.png
1. 添加 navigationPane。只绑定一个navigationPage
https://i-blog.csdnimg.cn/direct/d97bfa85d20f4ff99e9b42c8654a04f9.png
设置“showExpandButton” 可以隐蔽全屏显示
https://i-blog.csdnimg.cn/direct/2f7ab7ad760b4df796d860ff1d0715e3.png
https://i-blog.csdnimg.cn/direct/b33fbb33890e48e5816b86a01db067c4.pnghttps://i-blog.csdnimg.cn/direct/1633e80eddb1486ea21b2c1a88918618.png
2. 用代码向其中参加checkedit控件
private void LoadColumsSelect()
{
foreach (GridBand band in bandedGridView1.Bands)
{
foreach (BandedGridColumn column in band.Columns)
{
if (column.Name== "姓名")
{
continue;
}
else if (column.Name == "性别")
{
continue;
}
else if (column.Name == "年龄")
{
continue;
}
else if (column.Name == "住址")
{
continue;
}
else
{
CheckEdit checkEdit = new CheckEdit();
checkEdit.Text = column.Name;
checkEdit.Properties.GlyphAlignment = DevExpress.Utils.HorzAlignment.Far;
checkEdit.Dock = DockStyle.Bottom;
checkEdit.Checked = true;
checkEdit.Properties.FullFocusRect = true;
checkEdit.TabIndex = column.AbsoluteIndex;
checkEdit.CheckedChanged += new EventHandler(checkEditCheckedChanged);
navigationPage1.Controls.Add(checkEdit);
}
}
}
}
private void checkEditCheckedChanged(object sender, EventArgs e)
{
CheckEdit checkEdit = sender as CheckEdit;
int checkEditIndex = checkEdit.TabIndex;
if (checkEdit.Checked)
{
bandedGridView1.Columns.VisibleIndex = checkEditIndex;
bandedGridView1.Columns.Visible = true;
}
else
{
bandedGridView1.Columns.Visible = false;
}
} 大概
private void Load()
{
for (int i = gridView.Columns.Count - 1; i >= 0; i--)
{
gridView.Columns.Visible = false;
CheckEdit checkEdit = new CheckEdit();
checkEdit.Text = gridView.Columns.GetTextCaption();
checkEdit.Checked=true;
checkEdit.Properties.GlyphAlignment = DevExpress.Utils.HorzAlignment.Far;
checkEdit.Dock = DockStyle.Top;
checkEdit.Properties.FullFocusRect = true;
checkEdit.TabIndex = gridView.Columns.AbsoluteIndex;
checkEdit.CheckedChanged += new EventHandler(checkEditCheckedChanged);
navigationPage.Controls.Add(checkEdit);
}
}
private void checkEditCheckedChanged(object sender, EventArgs e)
{
CheckEdit checkEdit = sender as CheckEdit;
int checkEditIndex = checkEdit.TabIndex;
if (checkEdit.Checked)
{
gridView.Columns.VisibleIndex = checkEditIndex;
gridView.Columns.Visible = true;
}
else
{
gridView.Columns.Visible = false;
}
}
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]