473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Simple Datagridview question

Hi,

I have a datagridview, with column header and on the lefthandside the
rowselector. I would like to do the following 2

1. When the user click ONLY the row selector or inside the gridview
(not in header), I would like to do display a message.
2. I have a context menu associated with the datagirdview and when user
right click, I get my context menu but at the same time, I want to
select the row where the user right clicked.

I used the hittest for (1) but when I double click on the leftmost row
selector, I am getting none, same like double clicking the header. Is
there a way we can distinguish between header and row selector?

For (2) I did the following but no effect, but I do get the context
menu though.
private void dataGridView1_CellMouseClick(object sender,
DataGridViewCellMouseEventArgs e)
{
if ((e.Button == MouseButtons.Right) && (e.RowIndex >= 0))
dataGridView1.Rows[e.RowIndex].Selected = true;
}

Thanks in advance.

Jun 23 '06 #1
0 1949

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
1
by: gon_no1 | last post by:
Hi there! I have created a DataGridView in VC++ (in Visual Studio 2005, .NET 2.0), say its named "myGrid". I am trying to use its protected method, SetSelectedRowCore, to say highlight...
2
by: michael sorens | last post by:
I have been trying to figure out how to use DataSets, BindingSources, DataGridViews, and XML together, but it is a challenge. I understand how to populate a DataGridView with XML basically as: ...
3
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As...
14
by: giddy | last post by:
ok i have a datagridview in my app and i have a function defined like so: public void FillColumns(ref DataGridView theDGV) when i call it ... like this : FillColumns(ref dataGridView2); i...
2
by: Steve Richter | last post by:
what is the best way to use DataGridView to view data from large database tables? Where the sql select statement might return millions of rows? string connectionString =...
1
by: dvestal | last post by:
Font font = new Font("Courier New", 8); Graphics g = listBox1.CreateGraphics(); int width1 = g.MeasureString(" ", font).Width; // a space int width2 = g.MeasureString("S", font).Width; width1...
3
by: =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post by:
New to databinding in vs2005, I always did it manually in 2003. I have no problem loading comboboxes, and a change in that combobox changes the data in the textboxes but I can not figure out a way...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: Cat | last post by:
Hi. What I am trying to do is very simple, but it somehow didn't work. I had created a table in a .MDB file, That table had 5 fields and one of which was the primary key. I added a DataGridView...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.