VGridOptionsBehavior.AllowRecordComparison Property
Gets or sets whether record comparison is enabled.
Namespace: DevExpress.XtraVerticalGrid
Assembly: DevExpress.XtraVerticalGrid.v24.2.dll
Declaration
[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AllowRecordComparison { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Boolean | true | true to allow users to compare records; otherwise, false |
Property Paths
You can access this nested property as listed below:
Object Type | Path to AllowRecordComparison |
---|---|
VGridControlBase |
|
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:
- Ensure that the
AllowRecordComparison
property is enabled. - Set the ShowRecordHeaders property to true.
- Specify content for record headers. To do this, use the RecordHeaderFormat property or CustomRecordHeaderDisplayText event. Record headers appear only if you assign content to them.
Example
The following example toggles the AllowRecordComparison property:
private void btnToggleComparison_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
vGridControl1.OptionsBehavior.AllowRecordComparison = !vGridControl1.OptionsBehavior.AllowRecordComparison;
}
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:
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.
To allow multiple record selection and use the AddSelectionToComparison method, set the MultiSelect property to true.
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();
}