列表shift多选,修复客服无法筛选店铺bug
This commit is contained in:
1 parent
b27c473c99
commit
679bae7c42
11 files changed
+272
-110
No files matched your search
@@ -7,16 +7,19 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using NaiBa.Util.Extension;
|
||||
|
||||
namespace TemuKJD.UserComponent
|
||||
{
|
||||
public class DataGridViewEx : DataGridView
|
||||
{
|
||||
Form parentForm = null;
|
||||
public DataGridViewEx()
|
||||
{
|
||||
BackgroundColor = Color.White;
|
||||
AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(249, 249, 249);
|
||||
RowPostPaint += DataGridViewEx_RowPostPaint;
|
||||
this.CellContentClick += DataGridViewEx_CellContentClick;
|
||||
|
||||
this.SetStyle(
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
@@ -24,6 +27,94 @@ namespace TemuKJD.UserComponent
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.AllPaintingInWmPaint,
|
||||
true);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
System.Threading.Thread.Sleep(100);
|
||||
parentForm = FindForm();
|
||||
if (parentForm != null)
|
||||
{
|
||||
parentForm.KeyPreview = true;
|
||||
parentForm.KeyDown += ParentForm_KeyDown;
|
||||
parentForm.KeyUp += ParentForm_KeyUp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DataGridViewEx_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0)
|
||||
return;
|
||||
var colIndex = this.Columns.Cast<DataGridViewColumn>().FirstOrDefault(c => c is DataGridViewCheckBoxColumn).Index;
|
||||
if (colIndex < 0 || e.ColumnIndex != colIndex)
|
||||
return;
|
||||
|
||||
rowIndex1 = rowIndex2;
|
||||
rowIndex2 = e.RowIndex;
|
||||
if (IsShiftDown)
|
||||
{
|
||||
if (rowIndex1 > -1 && rowIndex2 > -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (rowIndex1 > rowIndex2)
|
||||
{
|
||||
for (int i = rowIndex2; i <= rowIndex1 - 1; i++)
|
||||
{
|
||||
this.Rows[i].Cells[colIndex].Value = this.Rows[rowIndex1].Cells[colIndex].Value;
|
||||
}
|
||||
this.Rows[rowIndex1].Cells[rowIndex1].Value = !this.Rows[rowIndex1].Cells[rowIndex2].Value.ParseToBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = rowIndex1; i <= rowIndex2 - 1; i++)
|
||||
{
|
||||
this.Rows[i].Cells[colIndex].Value = this.Rows[rowIndex1].Cells[colIndex].Value;
|
||||
}
|
||||
this.Rows[rowIndex1].Cells[rowIndex2].Value = !this.Rows[rowIndex1].Cells[rowIndex1].Value.ParseToBool();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
//rowIndex1 = -1;
|
||||
//rowIndex2 = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rowIndex1 = -1;
|
||||
int rowIndex2 = -1;
|
||||
bool IsShiftDown = false;
|
||||
private void ParentForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Shift:
|
||||
case Keys.ShiftKey:
|
||||
case Keys.LShiftKey:
|
||||
case Keys.RShiftKey:
|
||||
IsShiftDown = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void ParentForm_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Shift:
|
||||
case Keys.ShiftKey:
|
||||
case Keys.LShiftKey:
|
||||
case Keys.RShiftKey:
|
||||
IsShiftDown = false;
|
||||
rowIndex1 = -1;
|
||||
rowIndex2 = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Color _BorderColor = Color.FromArgb(63, 126, 255);
|
||||
|
||||
Reference in new issue
Block a user