windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridoptionsbehavior-7e931051.md
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
[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AllowRecordComparison { get; set; }
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property AllowRecordComparison As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | true |
true to allow users to compare records; otherwise, false
|
You can access this nested property as listed below:
| Object Type | Path to AllowRecordComparison |
|---|---|
| VGridControlBase |
.OptionsBehavior .AllowRecordComparison
|
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.
To allow users to compare records, follow the steps below:
AllowRecordComparison property is enabled.The following example toggles the AllowRecordComparison property:
private void btnToggleComparison_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
vGridControl1.OptionsBehavior.AllowRecordComparison = !vGridControl1.OptionsBehavior.AllowRecordComparison;
}
Private Sub btnToggleComparison_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
vGridControl1.OptionsBehavior.AllowRecordComparison = Not vGridControl1.OptionsBehavior.AllowRecordComparison
End Sub
To disable the header menu, set the EnableRecordHeaderMenu property to false.
Use the following methods to compare records:
AddToComparison — Adds a specific record to the comparison collection.
RemoveFromComparison — Removes a specific record from the comparison collection.
ShowComparison — Displays the selected records in a side-by-side comparison
HideComparison — Hides the comparison.
ClearComparison — Clears the comparison collection.
GetComparisonRecords — Gets the indices of records in the comparison collection.
AddSelectionToComparison — Adds the selected records to the comparison collection.
IsInComparison — Indicates whether a specific record is in the comparison collection.
The following example code shows how to display record headers, add records to the comparison collection, and display the comparison:
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();
}
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