gpt4 book ai didi

c# - 如何在 GridView 列中使用复选框存储库添加文本?

转载 作者:太空宇宙 更新时间:2023-11-03 13:00:04 26 4
gpt4 key购买 nike

我正在使用 DevExpress 控件。我有一个 GridControl,其列有 CheckboxRepository。我想在列中显示带有复选框(文本+复选框)的文本。我怎样才能实现它?

最佳答案

看看:How to display custom text next to a check box within the same cell

This task can be achieved by handling the following GridView/TreeList events: the CustomDrawCell event (CustomDrawNodeCell for the TreeList control) and the ShownEditor event. Within the CustomDraw~ event you should draw a checkbox and the necessary caption:

private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e) 
{
if (e.Column != treeList1.Columns["Check"])
return;

string caption = "Node ID: " + e.Node.Id.ToString();
DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo viewInfo = (e.EditViewInfo as DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo);

DevExpress.Utils.Drawing.CheckObjectInfoArgs checkInfo = viewInfo.CheckInfo;

checkInfo.Caption = caption;
checkInfo.Graphics = e.Graphics;
viewInfo.CheckPainter.CalcObjectBounds(checkInfo);
}

The ShownEditor event handler should adjust the editor's Properties.Caption property when the editor is being activated:

private void treeList1_ShownEditor(object sender, System.EventArgs e) 
{
DevExpress.XtraTreeList.TreeList tl = sender as DevExpress.XtraTreeList.TreeList;

if (tl.FocusedColumn != tl.Columns["Check"])
return;

(tl.ActiveEditor as DevExpress.XtraEditors.CheckEdit).Properties.Caption = "Node ID: " + tl.FocusedNode.Id.ToString();
}

关于c# - 如何在 GridView 列中使用复选框存储库添加文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32584653/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com