Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I am trying to use the CardCaptionFormat property to show a label and the value of a column, but I can't work out which column index to use. I have tried the following 3 methods and they all return the wrong column:

                                    Grid.vwCardView.CardCaptionFormat = "Subject: {" & Grid.vwCardView.Columns("TASK_SUBJECT").VisibleIndex & "}"
                                    Grid.vwCardView.CardCaptionFormat = "Subject: {" & Grid.vwCardView.Columns("TASK_SUBJECT").AbsoluteIndex & "}"
                                    Grid.vwCardView.CardCaptionFormat = "Subject: {" & Grid.vwCardView.Columns.IndexOf(Grid.vwCardView.Columns("TASK_SUBJECT") & "}"

                                    I have also tried:
                                                Dim CardCaption As String = "Subject: {" & Grid.vwCardView.Columns("TASK_SUBJECT").AbsoluteIndex & "}"
                                    Grid.vwCardView.CardCaptionFormat = CardCaption

                                    But they all return the value from the wrong column. What could i be doing wrong?

                                    Regards
                                    Justin

                                0

                                Hi Justin,

                                The CardView.CardCaptionFormat property used to format show caption passed the card rowHandle agument. You cannot use it to show card values. To show a custom card caption you should handle the CardView.CustomDrawCardCaption event and explicitly set the CardInfo.CaptionInfo.CardCaption property. I have prepared an example for you. It is in the attachment. The essential code follows:

                                    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

                                I'm looking forward to hearing from you.

                                Thanks,
                                Michael.

                                0

                                Thanks Michael for your repsonse, the code worked. However the help file and the GridMainDemo indicates that you can do this with the CardCaptionFormat. The help file at:

                                ms-help://DevExpress.NET.2005v6.2/DevExpress.XtraGrid/DevExpressXtraGridViewsCardCardViewCardCaptionFormattopic.htm

                                states that:

                                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.

                                It was this suggestion that I was following, but couldn't work out what the requied column index is. Have I mis-understood what the CardCaptionFormat is meant to be used for?

                                Thanks
                                Justin

                                0

                                Hi Justin,

                                Sorry for misleading you a little. The CardView.CardCaptionFormat property can be used to show column values as well. The argument index passed is the column AbsoluteIndex+1. Thus, in your instance you should use the following code:
                                Grid.vwCardView.CardCaptionFormat = "Subject: {" & (Grid.vwCardView.Columns("TASK_SUBJECT").AbsoluteIndex + 1) & "}"

                                Thanks,
                                Michael.

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners