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

Capture value in datagrid

In my C# winforms datagrid, how do I get the value of the selected cell? In
asp.net I can use:

dataGrid1.SelectedIndex

but SelectedIndex is not available in windows forms apps. HitTestInfo will
return the cell number and row number, but I need to get the actual contents
of the cell.

Thanks,
Dave
Nov 15 '05 #1
3 2139
The DataGrid's CurrentCell property returns the selected DataGridCell.

- Pete
"Dave Petersen" <da*******************@carlson.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
In my C# winforms datagrid, how do I get the value of the selected cell? In asp.net I can use:

dataGrid1.SelectedIndex

but SelectedIndex is not available in windows forms apps. HitTestInfo will return the cell number and row number, but I need to get the actual contents of the cell.

Thanks,
Dave

Nov 15 '05 #2
Use the Item property (which is the indexer in C#) to retrieve the value of
any cell.
Coordinates of the currently selected cell can indeed be obtained as
suggested by AirPete.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Dave Petersen" <da*******************@carlson.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
In my C# winforms datagrid, how do I get the value of the selected cell? In asp.net I can use:

dataGrid1.SelectedIndex

but SelectedIndex is not available in windows forms apps. HitTestInfo will return the cell number and row number, but I need to get the actual contents of the cell.

Thanks,
Dave


Nov 15 '05 #3
Thanks Pete,
Dave

"AirPete" <x@x.x> wrote in message
news:uu*****************@newsread2.news.pas.earthl ink.net...
The DataGrid's CurrentCell property returns the selected DataGridCell.

- Pete
"Dave Petersen" <da*******************@carlson.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
In my C# winforms datagrid, how do I get the value of the selected cell?

In
asp.net I can use:

dataGrid1.SelectedIndex

but SelectedIndex is not available in windows forms apps. HitTestInfo

will
return the cell number and row number, but I need to get the actual

contents
of the cell.

Thanks,
Dave


Nov 15 '05 #4

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

Similar topics

2
by: Nick | last post by:
I have a windows application wherein I have focus on a datagrid. Now when i hit the down arrow, I want to capture the event. However, my datagrid.KeyDown event handle is not getting invoked at all....
2
by: Saulo | last post by:
Hi, Well...I have a function in javascrit that capture the keys or event that a user to do... How I do to capture a control in the Datagrid ItemTemplate it's a Footer into the Template ??? ...
19
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred...
10
by: Tim Frawley | last post by:
I am attempting to detect a Shift+Tab in the KeyPress event for back navigation on a control that doesn't support this method. Does anyone have any ideas how to compare e.KeyChar to a ShiftTab? ...
3
by: Melson | last post by:
hi can anyone help me how can i capture ENTER keystroke when the cell in datagrid is in editing mode. I'm now creating a data entry form with primary key in header and details in datagrid. So...
1
by: hiuentsang | last post by:
Hi, How can I access the event generated by the click on a linkbutton in a datagrid? My requirement is like this... I've placed a linkbutton in a datagrid. The user clicks on it, and some...
0
by: crferguson | last post by:
I've been looking in every place I can to find a solution for this and I believe I've pieced a solid one together so I thought I'd share since I've found so much help on these groups... This is...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
2
bplacker
by: bplacker | last post by:
This seems like a simple question but, obviously, I cannot figure it out. I have a form which comes up with a datagrid, and from this datagrid I open up an edit form with the selected record from...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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
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.