473,831 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event when DataGridView row is clicked

Hi,

I need an event to fire off when someone clicks anyplace within a
DataGridView row, but whether I use CellContentClic k or CellClick, the
event only fires off when clicking on the text within the row and not
anyplace within the row. Is there someway for the event to fire off
regardless of where they click in the row?

Here's a snippet:
Private Sub dgvStuff_CellCo ntentClick(ByVa l sender As
System.Object, ByVal e As
System.Windows. Forms.DataGridV iewCellEventArg s) Handles
dgvStuff.CellCo ntentClick
'' blah blah blah my code goes here
End Sub

Thanks --

Alex
Sep 18 '08 #1
1 9719
I don't know if this fits your needs fully but worth trying
Private clickedCell As DataGridViewCel l
....
Private Sub GridView_MouseD own(ByVal sender As Object, ByVal e As
MouseEventArgs) Handles GridView.MouseD own
Dim hit As DataGridView.Hi tTestInfo = DataGridView1.H itTest(e.X,
e.Y)
If hit.Type = DataGridViewHit TestType.Cell Then
clickedCell =
DataGridView1.R ows(hit.RowInde x).Cells(hit.Co lumnIndex)
Dim CurrentCell As DataGridViewCel l =
GridView.Item(h it.ColumnIndex, hit.RowIndex)
End If
End Sub

"Alex" <sa*****@gmail. comwrote in message
news:40******** *************** ***********@p10 g2000prf.google groups.com...
Hi,

I need an event to fire off when someone clicks anyplace within a
DataGridView row, but whether I use CellContentClic k or CellClick, the
event only fires off when clicking on the text within the row and not
anyplace within the row. Is there someway for the event to fire off
regardless of where they click in the row?

Here's a snippet:
Private Sub dgvStuff_CellCo ntentClick(ByVa l sender As
System.Object, ByVal e As
System.Windows. Forms.DataGridV iewCellEventArg s) Handles
dgvStuff.CellCo ntentClick
'' blah blah blah my code goes here
End Sub

Thanks --

Alex

Sep 22 '08 #2

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

Similar topics

5
8725
by: Bob | last post by:
In a datagridview (vs2005, VB.net) I have two columns that are checkboxes. I need to check that only one of the two can be checked. Its not permissible to have the two selected to true, but they can both be false. I wrote code in the cellvalidating event as follows. Private Sub Datagrid1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles Datagrid1.CellValidating ...
9
2477
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the post event will always execuate after the system is completed... - I want to wrap this functionality in a framework, so I could possibly have 3 or 4 levels of inherited objects that need to have these pre / post events executed before and after the...
6
1830
by: Murray Hopkins | last post by:
Hi. THE QUESTION: How do I get a reference to my Object when processing an event handler bound to an html element ? CONTEXT: Sorry if it is a bit long. I am developing a JS calendar tool. One of the requirements is that the calendar will need to display a varying number of months (1..3)
8
19181
by: =?Utf-8?B?UmljaA==?= | last post by:
My from contains a "Move Next" button. When the user clicks on the "Move Next" button - several procedures get invoked and eventually, the dataset underlying the form will display main data from the next record and will display detail data in a datagridview also on the form which is related to the current main record in view. Another button ("Transfer Account") on the form can modify what detail data is related to the current main...
1
7624
by: Fred Chateau | last post by:
I am trying to run code that binds a DataGridView control on a TabPage. I inserted the code in the TabPage_Click event, but when the tab is clicked, the event never fires. I understand it is necessary to set the StandardClick style to enabled. I can't seem to find a StandardClick style on the TabControl, but I used the following code in the Form_Load event. this.SetStyle(ControlStyles.StandardClick, true); this.UpdateStyles();
0
1513
by: ajanu81 | last post by:
hi all, i am new to this forum. i am using a windows application using C#. I am using a datagridview to display contents of a xml file. say i have a xml file like this. <xml version="1.0" encoding="UTF-8"> <maincategory> <cat1> <title>Category1</title>
0
1182
by: quangnd0003 | last post by:
I have a event to Cancel Delete of user : private void dataGridViewKV_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { string maKV = e.Row.Cells.FormattedValue.ToString(); string tenKV = e.Row.Cells.FormattedValue.ToString(); string message = string.Format( "Are you sure want to delete {0} ?", tenKV, maKV);
0
4086
by: NvrBst | last post by:
How does "e.CellStyle" work? When I do something like if(e.ColumnIndex == 0 && e.RowIndex == 0) DataGridView.Rows.DefaultCellStyle.BackColor = Color.Orange; then the entire table goes orange; not just the 1st row. When I do if(e.RowIndex == 0) e.CellStyle.BackColor = Color.Orange; then 1st row goes orange only. Is it better to set the
2
8458
by: hnpatel | last post by:
Hi to All, How to use mouse click event for datagridview in c# in vs2005? I m using datagridview in c# application.I had bound data in datagridview.I want to display data in textbox when i click on appropriate row of the datagridview.Grid has only one event "cellcontentclick" is displayed.But i want to use "cellclick" or "selectionchanged" event of datagridview. So plz help me...How to do this....? Thax in advance.......
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10538
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.