Programming Dreamer
Programming Dreamer

Reputation: 235

C#: Detect Mouse Events (Enter, Leave, Down, etc.)

I need to have this event for my cursor interacting with my textbox IN A GRIDVIEW. I tried using TextBox1_MouseEnter or any sort but IntelliSense can't help me. Am I missing a namespace? I have NO IDEA where to start to control mouse events.

Upvotes: 1

Views: 190

Answers (1)

Aftab Ahmed
Aftab Ahmed

Reputation: 1737

There is no event on Gridview TextBox1_MouseEnter instead try this code.

private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
    dataGridView1[e.ColumnIndex, e.RowIndex].Style.SelectionBackColor = Color.Blue;
}

private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
    dataGridView1[e.ColumnIndex, e.RowIndex].Style.SelectionBackColor = Color.Empty;
}

Upvotes: 2

Related Questions