473,386 Members | 1,733 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,386 software developers and data experts.

How can i get a clicked cell's index in a DataGridView

I m using a data gridveiw control in Window forms application and i want to delete the record on which the user clicks, for this purpose i need to get the index of the clicked row.

How can i get these.........
Kindly tell me if anybody has a solution.........
Dec 6 '07 #1
4 2402
Airslash
221 100+
this.datagridview.SelectMode = FullRowSelect // Set this in the proprty manager
this.datagridview.SelectedRows[0] // is your selected row.
Dec 6 '07 #2
Plater
7,872 Expert 4TB
If need be, there are also events that fire when a cell/row is clicked
Dec 6 '07 #3
Frinavale
9,735 Expert Mod 8TB
I m using a data gridveiw control in Window forms application and i want to delete the record on which the user clicks, for this purpose i need to get the index of the clicked row.

How can i get these.........
Kindly tell me if anybody has a solution.........
There is a "Delete" button that you can add to your GridView as a column...so that if the user wants to delete a row they can click this button.

This button will thrown a RowDeleting event.
When you handle this event in your code, you will be passed a variable of type GridViewDeleteEventArgs. This variable name is "e".

From this variable you can determine what row the user has picked to delete by retriving the value from the GridViewDeleteEventArg varaible's RowIndex property:

IE: e.RowIndex

Cheers

-Frinny
Dec 6 '07 #4
Plater
7,872 Expert 4TB
Your post title stated the GridView object, but in your post you refered to it as a windows application, which would make it a DataGridView object.
I have changed the title of the post to reflect that.
Dec 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Charlie | last post by:
Hi: Using the WinForms DataGrid, I would like to have the entire row highlight rather than just the cell that was last clicked. How do you do this? Thanks, Charlie
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
10
by: steve | last post by:
Hi All I would like to be able to change the cell borders on certain cells to none at runtime to make a group of cells appear to be merged I have tried the following in the cellformatting...
3
by: Henry Jones | last post by:
I am using VB.NET VS 2005 and I have a datagridview bound to a table. This table has rate information on bank loans. The fiels are ProductName, MinDeposit, Rate, and PreviousRate On the grid...
3
by: Przemek M. Zawada | last post by:
Dear Group, I'm developing sample window form, using DataGridView control, which is filled with data through BindingSource, which is based on type of object, as follow: public sampleClass {...
1
by: PawelR | last post by:
Hi Group, In my application I have DataTable which is displayed in DataGridView via DataView: DataView myView = new DataView(myTable); myDataGridView.DataSource = myView; One column im...
2
by: clogg02 | last post by:
Hi, I have bound a DataView to a DataGridView using this.dataGridView1.DataSource = new DataView(this.dataTable1); I allow for sorting of the datagridview using clicks on the headers. Later...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
0
by: hydro123 | last post by:
I am using VC++2008 and am trying to read data enetered in unbound datagridview to implement in function. Under button_click event I entered the following: // initialize varaibles from...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.