Answer the question
In order to leave comments, you need to log in
How to reduce system load when working with Cursor in MouseMove on dataGridView?
WinForms project, it contains a form with a dataGridView on which the MouseMove event hangs. The form is expanded to full screen. There is also a working timer.
Here I determine the coordinates of the cell over which the mouse cursor is located:
private Point A1;
int cellX;
int cellY;
private void dataGridView1_MouseMove(object sender, MouseEventArgs e)
{
cellX = e.X / dataGridView1.Columns[0].Width;
cellY = e.Y / dataGridView1.RowTemplate.Height;
this.Text = "cellX: " + cellX + " cellY: " + cellY;
}
A1.X = dataGridView1.Left + e.X;
A1.Y = 200 + dataGridView1.RowTemplate.Height/2;
Cursor.Position = A1; //как я понял, тормоза из-за этой строчки.
Answer the question
In order to leave comments, you need to log in
The problem was partially solved by placing the problematic line in if:
if (kk == 3)
{
Cursor.Position = A1;
kk = 0;
}
kk++;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question