Back to Devexpress

VGridControl.RecordHeaderFormat Property

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrol-7b2c1709.md

latest7.5 KB
Original Source

VGridControl.RecordHeaderFormat Property

Gets or sets the format string used to generate header text for the control’s records.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

csharp
[XtraSerializableProperty]
public string RecordHeaderFormat { get; set; }
vb
<XtraSerializableProperty>
Public Property RecordHeaderFormat As String

Property Value

TypeDescription
String

The record header format string.

|

Remarks

Set the OptionsView.ShowRecordHeaders property to true to enable record headers.

Run Demo: PC Market

You can specify record header content as follows:

The record format supports the following elements:

Example

The following format string displays a hyperlink, and values of the ‘ProcName’ and ‘ModelPrice’ fields in record headers.

csharp
vGridControl1.OptionsView.AllowHtmlText = true;
vGridControl1.Appearance.RecordHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
vGridControl1.RecordHeaderFormat = "
<size=10><b>{ProcName}</b>

" +
    "<size=12>{ModelPrice}</size>

" +
    "<size=7><b><href=shoppingcart>ADD TO CART</href>

";
vb
VGridControl1.OptionsView.AllowHtmlText = True
VGridControl1.Appearance.RecordHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap
VGridControl1.RecordHeaderFormat = "
<size=10><b>{ProcName}</b>

" &
    "<size=12>{ModelPrice}</size>

" &
    "<size=7><b><href=shoppingcart>ADD TO CART</href>

"

Example

In the following example, a Vertical Grid’s record headers contain hyperlinks that display employees’ e-mails. The VGridOptionsBehavior.HyperlinkClickMode property is set to CtrlClick to allow users to activate hyperlinks on a mouse click when the CTRL key is pressed down. The VGridControlBase.HyperlinkClick event handler starts a process that opens a clicked hyperlink.

csharp
private void Form1_Load(object sender, EventArgs e) {
    BindingList<Message> list = new BindingList<Message>();
    list.Add(new Message() { Date = DateTime.Now, Email = "[email protected]", From = "John Heart", PlainText = "Hello All Please remember that I’ve rescheduled...", Subject = "DevAV Annual Performance Review" });
    list.Add(new Message() { Date = DateTime.Now, Email = "[email protected]", From = "Violet Bailey", PlainText = "Good Day Morgan I’ve been asked by the sales team...", Subject = "Artwork for packaging" });
    vGridControl1.DataSource = list;
    vGridControl1.OptionsView.ShowRecordHeaders = true;
    vGridControl1.OptionsView.AllowHtmlText = true;
    vGridControl1.RecordHeaderFormat = "<b>{From}</b>
<a href=mailto:{Email}>{Email}</a>";
    vGridControl1.Appearance.RecordHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
    vGridControl1.RecordWidth = 150;
    vGridControl1.OptionsBehavior.HyperlinkClickMode = DevExpress.Utils.Drawing.HyperlinkClickMode.CtrlClick;
    vGridControl1.HyperlinkClick += VGridControl1_HyperlinkClick;
}

private void VGridControl1_HyperlinkClick(object sender, DevExpress.XtraVerticalGrid.Events.HyperlinkClickEventArgs e) {
    if (e.Link.StartsWith("mailto:"))
        System.Diagnostics.Process.Start(e.Link);
}

public class Message {
    public DateTime Date { get; set; }
    public string From { get; set; }
    public string Email { get; set; }
    public string Subject { get; set; }
    public string PlainText { get; set; }
}
vb
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim list As New BindingList(Of Message)()
    list.Add(New Message() With {.Date = DateTime.Now, .Email = "[email protected]", .From = "John Heart", .PlainText = "Hello All Please remember that I’ve rescheduled...", .Subject = "DevAV Annual Performance Review"})
    list.Add(New Message() With {.Date = DateTime.Now, .Email = "[email protected]", .From = "Violet Bailey", .PlainText = "Good Day Morgan I’ve been asked by the sales team...", .Subject = "Artwork for packaging"})
    VGridControl1.DataSource = list
    VGridControl1.OptionsView.ShowRecordHeaders = True
    VGridControl1.OptionsView.AllowHtmlText = True
    VGridControl1.RecordHeaderFormat = "<b>{From}</b>
<a href=mailto:{Email}>{Email}</a>"
    VGridControl1.Appearance.RecordHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap
    VGridControl1.RecordWidth = 150
    VGridControl1.OptionsBehavior.HyperlinkClickMode = DevExpress.Utils.Drawing.HyperlinkClickMode.CtrlClick
    AddHandler VGridControl1.HyperlinkClick, AddressOf VGridControl1_HyperlinkClick
End Sub

Private Sub VGridControl1_HyperlinkClick(ByVal sender As Object, ByVal e As DevExpress.XtraVerticalGrid.Events.HyperlinkClickEventArgs)
    If e.Link.StartsWith("mailto:") Then
        System.Diagnostics.Process.Start(e.Link)
    End If
End Sub

Public Class Message
    Public Property Date As DateTime
    Public Property From() As String
    Public Property Email() As String
    Public Property Subject() As String
    Public Property PlainText() As String
End Class

See Also

VGridControl Class

VGridControl Members

DevExpress.XtraVerticalGrid Namespace