473,385 Members | 1,569 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.

Get the value of one cell from a DataGridView?

Hello:

I have a DataGridView control and I want to doubleclick a row and get a
single cell value.

Here's a snippet:

private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that was
doubleclicked]

}

This should be a simple task but I can't seem to get it.

Thanks

Edwin
Feb 21 '07 #1
3 78017
Edwin Smith <sm**********@aol.comschrieb:
private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that was
doubleclicked]

}
e.RowIndex contains the index of the row you double-clicked.
This should give you a start...

Markus
Feb 21 '07 #2

"Edwin Smith" <sm**********@aol.comschreef in bericht
news:e4**************@TK2MSFTNGP04.phx.gbl...
Hello:

I have a DataGridView control and I want to doubleclick a row and get a
single cell value.

Here's a snippet:

private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that
was doubleclicked]

}

This should be a simple task but I can't seem to get it.

Thanks

Edwin



textbox1.Text =
pATIENTSDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();

Regards,
Anne
Feb 21 '07 #3

"AvdP" <apuntvdpuntploegatplanetpuntnlwrote in message
news:45**********************@text.nova.planet.nl. ..
>
"Edwin Smith" <sm**********@aol.comschreef in bericht
news:e4**************@TK2MSFTNGP04.phx.gbl...
>Hello:

I have a DataGridView control and I want to doubleclick a row and get a
single cell value.

Here's a snippet:

private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that
was doubleclicked]

}

This should be a simple task but I can't seem to get it.

Thanks

Edwin


textbox1.Text =
pATIENTSDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();

Regards,
Anne
Works great! Thanks.

I had already figured out the e.RowIndex and e.ColumnIndex values. I just
couldn't figure out how to use them to get the cell I wanted.

Edwin
Feb 21 '07 #4

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

Similar topics

1
by: Morten Snedker | last post by:
How do I the value of a cell in a datagridview, before it is updated? I wish to validate the "visible" value, not the actual value (cell/row hasn't been updated yet). Thanks in advance. ...
0
by: None | last post by:
Hi, I'm using DataGridView in my Windows Forms project. I need to know how we can insert an image into the specified cell . I tried with the following code.
2
by: paolol | last post by:
Hi, I have a datagridview and at the doubleclick event I will like to open a new window with a collection of data from an ADO DB , but I don't know how to get the value of a cell in the clicked...
1
by: BisterBooster | last post by:
Hi, Can someone help me for next problem How to for using ENTER key to move to the right cell instead of the TAB key Many thanks in advance Marc.
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...
0
by: pujabebisunar | last post by:
hi can u tell me how can i pass my textbox value into datagridview .i have 3textbox,1add button and 1datagridview
1
by: =?Utf-8?B?QnJpYW5ESA==?= | last post by:
Hi I am looking for examples of how to find the row index in a Datagridview control by comparing a string value to the value in a Cell. Thanks Brian
2
by: HenrikRinder | last post by:
This is a silly question, but now I have spent hours trying to figure it out. Thus, asking this forum: Our application GUI has a .NET PropertyGrid. Our customers don't find it intuitive to...
0
by: isisqiero | last post by:
I use a list of names in a Word document as the value of SELECT statement's parameter. However, my datagridview shows only the column names without the data I am hoping to see. Public Class Form1 ...
0
by: visweswaran2830 | last post by:
Hi, I am having datagridview in that I have datagridview combobox column and noraml textfield. I want to know that how can I load selected value in that combox box when I am loading all entered...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.