ToB企服应用市场:ToB评测及商务社交产业平台
标题:
c# navigationPane、navigationPage设置可选择列显示
[打印本页]
作者:
熊熊出没
时间:
2024-10-29 01:45
标题:
c# navigationPane、navigationPage设置可选择列显示
实现效果
1. 添加 navigationPane。只绑定一个navigationPage
设置“showExpandButton” 可以隐蔽全屏显示
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[checkEditIndex].VisibleIndex = checkEditIndex;
bandedGridView1.Columns[checkEditIndex].Visible = true;
}
else
{
bandedGridView1.Columns[checkEditIndex].Visible = false;
}
}
复制代码
大概
private void Load()
{
for (int i = gridView.Columns.Count - 1; i >= 0; i--)
{
gridView.Columns[i].Visible = false;
CheckEdit checkEdit = new CheckEdit();
checkEdit.Text = gridView.Columns[i].GetTextCaption();
checkEdit.Checked=true;
checkEdit.Properties.GlyphAlignment = DevExpress.Utils.HorzAlignment.Far;
checkEdit.Dock = DockStyle.Top;
checkEdit.Properties.FullFocusRect = true;
checkEdit.TabIndex = gridView.Columns[i].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[checkEditIndex].VisibleIndex = checkEditIndex;
gridView.Columns[checkEditIndex].Visible = true;
}
else
{
gridView.Columns[checkEditIndex].Visible = false;
}
}
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/)
Powered by Discuz! X3.4