我正在尝试使 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)到网格,那么您可以在格式字符串中分配 Name
和 Surname
列的列索引,然后它会自动反射(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/