Back to Devexpress

VGridOptionsBehavior.AllowRecordComparison Property

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridoptionsbehavior-7e931051.md

latest7.5 KB
Original Source

VGridOptionsBehavior.AllowRecordComparison Property

Gets or sets whether record comparison is enabled.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AllowRecordComparison { get; set; }
vb
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property AllowRecordComparison As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true to allow users to compare records; otherwise, false

|

Property Paths

You can access this nested property as listed below:

Object TypePath to AllowRecordComparison
VGridControlBase

.OptionsBehavior .AllowRecordComparison

|

Remarks

The VGridControl allows you to compare records if the AllowRecordComparison property is set to true.

Checkboxes appear when users hover the mouse pointer over record headers. Use checkboxes to add or remove records to/from the comparison. Another way to do this is to right-click record headers and choose Add to Comparison and Remove from Comparison.

To display the comparison, right-click the record header and choose Show Comparison from the context menu. Choose other options in the context menu like Hide Comparison and Clear Comparison to hide or clear the comparison.

Compare Records

To allow users to compare records, follow the steps below:

Example

The following example toggles the AllowRecordComparison property:

csharp
private void btnToggleComparison_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
    vGridControl1.OptionsBehavior.AllowRecordComparison = !vGridControl1.OptionsBehavior.AllowRecordComparison;
}
vb
Private Sub btnToggleComparison_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
    vGridControl1.OptionsBehavior.AllowRecordComparison = Not vGridControl1.OptionsBehavior.AllowRecordComparison
End Sub

Disable the Record Header Context Menu

To disable the header menu, set the EnableRecordHeaderMenu property to false.

Compare Records in Code

Use the following methods to compare records:

The following example code shows how to display record headers, add records to the comparison collection, and display the comparison:

csharp
using DevExpress.Utils;
using DevExpress.XtraVerticalGrid;

private void Form1_Load(object sender, EventArgs e) {
    // Display record headers.
    vGridControl1.OptionsView.ShowRecordHeaders = true;
    // Display FirstName and LastName field values in record headers.
    vGridControl1.RecordHeaderFormat = "{FirstName} {LastName}";
    // Add records to the comparison collection.
    vGridControl1.AddToComparison(4); 
    vGridControl1.AddToComparison(5);
    vGridControl1.AddToComparison(7);
    // Display the comparison
    vGridControl1.ShowComparison();
}
vb
Imports DevExpress.Utils
Imports DevExpress.XtraVerticalGrid 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    ' Display record headers.
    vGridControl1.OptionsView.ShowRecordHeaders = True
    ' Display FirstName and LastName field values in record headers.
    vGridControl1.RecordHeaderFormat = "{FirstName} {LastName}"
    ' Add records to the comparison collection.
    vGridControl1.AddToComparison(4) 
    vGridControl1.AddToComparison(5) 
    vGridControl1.AddToComparison(7)
    ' Display the comparison
    vGridControl1.ShowComparison()
End Sub

See Also

AddToComparison(Int32)

AddSelectionToComparison()

RemoveFromComparison(Int32)

ShowComparison()

HideComparison()

ClearComparison()

GetComparisonRecords()

VGridOptionsBehavior Class

VGridOptionsBehavior Members

DevExpress.XtraVerticalGrid Namespace