Quick Filters display moveup and movedown buttons appropriately
This commit is contained in:
parent
a75932d1f4
commit
5611431abf
@ -32,10 +32,10 @@
|
|||||||
this.saveBtn = new System.Windows.Forms.Button();
|
this.saveBtn = new System.Windows.Forms.Button();
|
||||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
this.Original = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.Original = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.Delete = new System.Windows.Forms.DataGridViewButtonColumn();
|
this.Delete = new DisableButtonColumn();
|
||||||
this.Filter = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.Filter = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.MoveUp = new System.Windows.Forms.DataGridViewButtonColumn();
|
this.MoveUp = new DisableButtonColumn();
|
||||||
this.MoveDown = new System.Windows.Forms.DataGridViewButtonColumn();
|
this.MoveDown = new DisableButtonColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -145,9 +145,9 @@
|
|||||||
private System.Windows.Forms.Button saveBtn;
|
private System.Windows.Forms.Button saveBtn;
|
||||||
private System.Windows.Forms.DataGridView dataGridView1;
|
private System.Windows.Forms.DataGridView dataGridView1;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn Original;
|
private System.Windows.Forms.DataGridViewTextBoxColumn Original;
|
||||||
private System.Windows.Forms.DataGridViewButtonColumn Delete;
|
private DisableButtonColumn Delete;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn Filter;
|
private System.Windows.Forms.DataGridViewTextBoxColumn Filter;
|
||||||
private System.Windows.Forms.DataGridViewButtonColumn MoveUp;
|
private DisableButtonColumn MoveUp;
|
||||||
private System.Windows.Forms.DataGridViewButtonColumn MoveDown;
|
private DisableButtonColumn MoveDown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,10 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using LibationFileManager;
|
using LibationFileManager;
|
||||||
|
|
||||||
namespace LibationWinForms.Dialogs
|
namespace LibationWinForms.Dialogs
|
||||||
{
|
{
|
||||||
|
public class DisableButtonColumn : DataGridViewButtonColumn
|
||||||
|
{
|
||||||
|
public DisableButtonColumn()
|
||||||
|
{
|
||||||
|
CellTemplate = new EditQuickFilters.DisableButtonCell();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public partial class EditQuickFilters : Form
|
public partial class EditQuickFilters : Form
|
||||||
{
|
{
|
||||||
private const string BLACK_UP_POINTING_TRIANGLE = "\u25B2";
|
private const string BLACK_UP_POINTING_TRIANGLE = "\u25B2";
|
||||||
@ -15,6 +24,25 @@ namespace LibationWinForms.Dialogs
|
|||||||
private const string COL_MoveUp = nameof(MoveUp);
|
private const string COL_MoveUp = nameof(MoveUp);
|
||||||
private const string COL_MoveDown = nameof(MoveDown);
|
private const string COL_MoveDown = nameof(MoveDown);
|
||||||
|
|
||||||
|
internal class DisableButtonCell : DataGridViewButtonCell
|
||||||
|
{
|
||||||
|
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
|
||||||
|
{
|
||||||
|
if ((OwningColumn.Name == COL_MoveUp && rowIndex == 0)
|
||||||
|
|| (OwningColumn.Name == COL_MoveDown && rowIndex == LastRowIndex)
|
||||||
|
|| OwningRow.IsNewRow)
|
||||||
|
{
|
||||||
|
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, null, null, null, cellStyle, advancedBorderStyle, paintParts ^ (DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.SelectionBackground));
|
||||||
|
|
||||||
|
ButtonRenderer.DrawButton(graphics, cellBounds, value as string, cellStyle.Font, false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LastRowIndex => DataGridView.Rows[^1].IsNewRow ? DataGridView.Rows[^1].Index - 1 : DataGridView.Rows[^1].Index;
|
||||||
|
}
|
||||||
|
|
||||||
public EditQuickFilters()
|
public EditQuickFilters()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user