public virtual ToolStripDropDown MakeColumnCommandMenu(ToolStripDropDown strip, int columnIndex)
{
OLVColumn column = this.GetColumn(columnIndex);
if (column == null)
return strip;
if (strip.Items.Count > 0)
strip.Items.Add(new ToolStripSeparator());
string label = String.Format(this.MenuLabelSortAscending, column.Text);
if (column.Sortable && !String.IsNullOrEmpty(label)) {
strip.Items.Add(label, ObjectListView.SortAscendingImage, (EventHandler)delegate(object sender, EventArgs args) {
this.Sort(column, SortOrder.Ascending);
});
}
label = String.Format(this.MenuLabelSortDescending, column.Text);
if (column.Sortable && !String.IsNullOrEmpty(label)) {
strip.Items.Add(label, ObjectListView.SortDescendingImage, (EventHandler)delegate(object sender, EventArgs args) {
this.Sort(column, SortOrder.Descending);
});
}
if (this.CanShowGroups) {
label = String.Format(this.MenuLabelGroupBy, column.Text);
if (column.Groupable && !String.IsNullOrEmpty(label)) {
strip.Items.Add(label, null, (EventHandler)delegate(object sender, EventArgs args) {
this.ShowGroups = true;
this.PrimarySortColumn = column;
this.PrimarySortOrder = SortOrder.Ascending;
this.BuildList();
});
}
}
if (this.ShowGroups) {
if (this.AlwaysGroupByColumn == column) {
label = String.Format(this.MenuLabelUnlockGroupingOn, column.Text);
if (!String.IsNullOrEmpty(label)) {
strip.Items.Add(label, null, (EventHandler)delegate(object sender, EventArgs args) {
this.AlwaysGroupByColumn = null;
this.AlwaysGroupBySortOrder = SortOrder.Ascending;
this.BuildList();
});
}
} else {
label = String.Format(this.MenuLabelLockGroupingOn, column.Text);
if (column.Groupable && !String.IsNullOrEmpty(label)) {
strip.Items.Add(label, null, (EventHandler)delegate(object sender, EventArgs args) {
this.ShowGroups = true;
this.AlwaysGroupByColumn = column;
this.AlwaysGroupBySortOrder = SortOrder.Ascending;
this.BuildList();
});
}
}
label = String.Format(this.MenuLabelTurnOffGroups, column.Text);
if (!String.IsNullOrEmpty(label)) {
strip.Items.Add(label, null, (EventHandler)delegate(object sender, EventArgs args) {
this.ShowGroups = false;
this.BuildList();
});
}
} else {
label = String.Format(this.MenuLabelUnsort, column.Text);
if (column.Sortable && !String.IsNullOrEmpty(label) && this.PrimarySortOrder != SortOrder.None) {
strip.Items.Add(label, null, (EventHandler)delegate(object sender, EventArgs args) {
this.Unsort();
});
}
}
return strip;
}