0
From now on I thank you for your time :D
I have a dataGridView filled by a Datatable
I want to select (fullRowSelect) it only when right-clicking and not left-clicking.
Someone helps?
0
From now on I thank you for your time :D
I have a dataGridView filled by a Datatable
I want to select (fullRowSelect) it only when right-clicking and not left-clicking.
Someone helps?
1
There is no "beautiful" way to do it, but there is always something to try:
dataGridView1.MouseClick += (s, e) =>
{
if (e.Button == MouseButtons.Left)
{
dataGridView1.ClearSelection();
dataGridView1.CurrentCell = null;
}
else if (e.Button == MouseButtons.Right)
{
var hitTest = dataGridView1.HitTest(e.X, e.Y);
dataGridView1.ClearSelection();
dataGridView1.Rows[hitTest.RowIndex].Selected = true;
}
};
With this solution there is some flickering, but I think you get what you want.
There are other solutions, but they will all give virtually the same.
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
Yes, it worked, you can tell me how to perform this action before a Contexmenustrip be shown?
– Gustavo Pedro
There would have to change the opening functioning of the
ContextMenu
. Isn’t it better to ask a new question? And, if possible, put code, otherwise you will have your question closed :)– João Martins
Man, I don’t understand, how am I going to put code from something I don’t know how to do, if it was something like, "Where’s the bug" or Best way to get to such a solution, yeah, but it’s not the case, what you want from code, I don’t understand, what part of the code of the project you want and what it helps?
– Gustavo Pedro
I’ll try to explain better: I have one Datagridview called Dgvlocacao, one Contexmenustrip called cmsLocation. When I right click on a row of the Dgvlocacao it is selected(And not with the left as is the natural control) But I wish it was possible to select before and after this appear the Komslocacao
– Gustavo Pedro