Added sorting to the Datagridview
This commit is contained in:
parent
b41fee13c1
commit
b342e6a195
|
@ -40,7 +40,7 @@
|
|||
//
|
||||
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.Cancel.Location = new System.Drawing.Point(405, 216);
|
||||
this.Cancel.Location = new System.Drawing.Point(384, 267);
|
||||
this.Cancel.Name = "Cancel";
|
||||
this.Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.Cancel.TabIndex = 0;
|
||||
|
@ -51,7 +51,7 @@
|
|||
// OK
|
||||
//
|
||||
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OK.Location = new System.Drawing.Point(324, 216);
|
||||
this.OK.Location = new System.Drawing.Point(303, 267);
|
||||
this.OK.Name = "OK";
|
||||
this.OK.Size = new System.Drawing.Size(75, 23);
|
||||
this.OK.TabIndex = 1;
|
||||
|
@ -71,8 +71,9 @@
|
|||
this.Comment});
|
||||
this.CommentGrid.Location = new System.Drawing.Point(12, 12);
|
||||
this.CommentGrid.Name = "CommentGrid";
|
||||
this.CommentGrid.Size = new System.Drawing.Size(468, 198);
|
||||
this.CommentGrid.Size = new System.Drawing.Size(447, 249);
|
||||
this.CommentGrid.TabIndex = 2;
|
||||
this.CommentGrid.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.OnColumnHeaderMouseClick);
|
||||
//
|
||||
// Comment
|
||||
//
|
||||
|
@ -88,7 +89,7 @@
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.Cancel;
|
||||
this.ClientSize = new System.Drawing.Size(492, 251);
|
||||
this.ClientSize = new System.Drawing.Size(471, 302);
|
||||
this.Controls.Add(this.CommentGrid);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Controls.Add(this.Cancel);
|
||||
|
@ -108,6 +109,6 @@
|
|||
private System.Windows.Forms.Button Cancel;
|
||||
private System.Windows.Forms.Button OK;
|
||||
private System.Windows.Forms.DataGridView CommentGrid;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Comment;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Comment;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using System.ComponentModel;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -8,11 +8,42 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class EditCommentsForm : Form
|
||||
{
|
||||
private IMovie _selectedMovie;
|
||||
private String _lastHeaderClicked;
|
||||
private Boolean _sortReverse;
|
||||
|
||||
public EditCommentsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_lastHeaderClicked = "";
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
public EditCommentsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void OnColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
SortColumn(CommentGrid.Columns[e.ColumnIndex]);
|
||||
}
|
||||
|
||||
private void SortColumn(DataGridViewColumn e)
|
||||
{
|
||||
ListSortDirection _direction;
|
||||
DataGridViewColumn _column = e;
|
||||
if (_lastHeaderClicked != _column.Name)
|
||||
{
|
||||
_sortReverse = false;
|
||||
}
|
||||
if (!_sortReverse)
|
||||
{
|
||||
_direction = ListSortDirection.Ascending;
|
||||
}
|
||||
else
|
||||
{
|
||||
_direction = ListSortDirection.Descending;
|
||||
}
|
||||
CommentGrid.Sort(_column, _direction);
|
||||
_lastHeaderClicked = _column.Name;
|
||||
_sortReverse = !_sortReverse;
|
||||
CommentGrid.Refresh();
|
||||
}
|
||||
|
||||
private void EditCommentsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue