c# - DevExpress CardView.CardCaptionFormat 问题

标签 c# devexpress

我正在尝试使 CardView1.CardCaptionFormat 条目具体化,例如 - 将每个特定人员的名字和姓氏显示为每张卡片的标题。

该代码有些工作,但它显示最后条目的名称和姓氏作为每张卡片的标题。

代码如下:

foreach (DataRow x in ds.Tables[0].Rows)
{
    strNameSurname = x[0].ToString() + " " + x[1].ToString();
    cardView1.CardCaptionFormat = x[0].ToString() + " " + x[1].ToString();
}

//x[0] is the name of an individual, x[1] is the surname of an individual.

希望大家说的清楚了!

最佳答案

CardView.CardCaptionFormat Property上查看以下备注文档topm”

The CardCaptionFormat property enables you to construct a caption text using static text together with the current record number and column values. The '{0}' character sequence is a placeholder for the current record number. Thus, the default property value specifies that card captions should contain 'Record N ' followed by the card number. To display column values within card captions, you need to use the desired column indexes. For instance, a '{1}' character sequence is a placeholder for the first column value, etc.

如果您的表绑定(bind)到网格,那么您可以在格式字符串中分配 NameSurname 列的列索引,然后它会自动反射(reflect)标题您的要求。

假设您的名字和姓氏列索引分别为 0 和 1.. 那么您的 CardView.CardCaptionFormat 属性将设置如下:

CardView.CardCaptionFormat = {0} + "" + {1}

来源:CardCaptionFormat
要显示自定义卡片标题,您应该处理 CardView.CustomDrawCardCaption 事件并显式设置 CardInfo.CaptionInfo.CardCaption 属性。我已经为你准备了一个例子。它在附件中。基本代码如下:

Private Sub CardView1_CustomDrawCardCaption(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Card.CardCaptionCustomDrawEventArgs) Handles CardView1.CustomDrawCardCaption
    Dim view As DevExpress.XtraGrid.Views.Card.CardView = sender
    Dim s As String = String.Format("Subject: {0}", view.GetRowCellDisplayText(e.RowHandle, "ProductName"))
    CType(e.CardInfo, DevExpress.XtraGrid.Views.Card.ViewInfo.CardInfo).CaptionInfo.CardCaption = s
End Sub

更多引用:
How to set different CardCaptionFormat for multiple cards
Card Caption

关于c# - DevExpress CardView.CardCaptionFormat 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12476448/

相关文章:

c# - 如何从 Unity 连接到数据库

c# - 确定类型等价

delphi - 计算最大字体大小

winforms - DevExpress DockPanel 宽度

c# - 呈现工作流程的控制

c# - 创建具有相同C#源构建的完整.net,PCL和dotnet核心程序集的单个源项目?

c# - 如何将 Angular 2.0 添加到现有的 ASP.NET MVC 应用程序

c# - 将通用列表绑定(bind)到转发器 - ASP.NET

asp.net-mvc - Devexpress Grid MVC 3 Razor 引擎

c# - WPF:单击鼠标右键/中键时 DoDragDrop 被打断