作業中に読み込み画面を表示しようとしています。私の仕事は、一度に 1 つのファイルを 1 つのセルから別のセルに移動することです。コードは完全に機能しています。しかしwhen i am trying to move a group of files the loading screen is coming and after job its stuck for 20-30 seconds
私は解決策を見つけました:its because after all the files are moved to the next column, my control is going to dataGridView1_DataBindingComplete
グリッドセルが私の状態に基づいて色を与えているのは、dataGridView1_DataBindingCompleteその作業を完全に削除したときです..しかし、私も色を与える必要があります..この状況にどう対処できるか教えてください.
コード:
private void button3_Click(object sender, EventArgs e)
{
Hide();
bool done = false;
ThreadPool.QueueUserWorkItem((x) =>
{
using (var splashForm = new Form4())
{
splashForm.Show();
while (!done)
Application.DoEvents();
splashForm.Close();
}
});
move(); // this is my function to move all files from one column to another
done = true;
Show();
}
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
string strVal = ini.ReadValue("Action", "Doc-Controller");
bool authenticated = true;
string textboxGroupName1 = ini.ReadValue("Action", "Fabricator");
if (authenticated == UserInCustomRole(textboxGroupName1))
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string fName1 = System.IO.Path.GetFileNameWithoutExtension(row.Cells[2].Value.ToString());
string fName2 = System.IO.Path.GetFileNameWithoutExtension(row.Cells[3].Value.ToString());
if (!string.IsNullOrEmpty(fName1) && !string.IsNullOrEmpty(fName2))
{
var f1 = GetValue(fName1.ToCharArray()[fName1.Length - 2]) * 16 + GetValue(fName1.ToCharArray()[fName1.Length - 1]);
var f2 = GetValue(fName2.ToCharArray()[fName2.Length - 2]) * 16 + GetValue(fName2.ToCharArray()[fName2.Length - 1]);
//if (System.IO.Path.GetFileName(fName1) != System.IO.Path.GetFileName(fName2))
if (f1 > f2)
{
//MessageBox.Show(fName1);
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.Yellow;
row.Cells[2].Style = style;
}
else if (f2 > f1)
{
//MessageBox.Show(fName1);
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.Yellow;
row.Cells[3].Style = style;
}
if (f1 == f2)
{
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.Plum;
row.Cells[3].Style = style;
row.Cells[2].Style = style;
}
}
}
}
if (authenticated == UserInCustomRole(strVal))
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string fName1 = System.IO.Path.GetFileNameWithoutExtension(row.Cells[3].Value.ToString());
string fName2 = System.IO.Path.GetFileNameWithoutExtension(row.Cells[4].Value.ToString());
if (!string.IsNullOrEmpty(fName1) && !string.IsNullOrEmpty(fName2))
{
var f1 = GetValue(fName1.ToCharArray()[fName1.Length - 2]) * 16 + GetValue(fName1.ToCharArray()[fName1.Length - 1]);
var f2 = GetValue(fName2.ToCharArray()[fName2.Length - 2]) * 16 + GetValue(fName2.ToCharArray()[fName2.Length - 1]);
//if (System.IO.Path.GetFileName(fName1) != System.IO.Path.GetFileName(fName2))
if (f1 > f2)
{
//MessageBox.Show(fName1);
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.Yellow;
row.Cells[3].Style = style;
}
else if (f2 > f1)
{
//MessageBox.Show(fName1);
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.Yellow;
row.Cells[4].Style = style;
}
if (f1 == f2)
{
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.Plum;
row.Cells[4].Style = style;
row.Cells[3].Style = style;
}
}
}
}
}
private int GetValue(char ch)
{
if (ch >= 48 && ch <= 57)
return ch - 48;
else if (ch >= 65 && ch <= 90)
return ch - 65 + 10;
else
return 0;
}