By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,564 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,564 IT Pros & Developers. It's quick & easy.

Selecting full row of a DataGrid

P: n/a
Hello All,

I am new to CSharp. Somebody please tell me how to select the entire row in
a data grid on a mouse click event on any of the cell.

Thanx in advance
Dhannu
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dhanraj,

A datagrid (winform) exist from a showing control of the data an the data in
a underlying datasource.

When you want to get all data, you have to get that from that datasource.

This is a short answer because a lot depends what is that underlying
datasource.

I hope this helps anyway

Cor
Nov 16 '05 #2

P: n/a
Hi Dhanraj,

Look for DataDrid's members:
- method Select(int rowIndex)
- property CurrentRowIndex

But i'm not so sure about Click event...

HTH
Marcin
Hello All,

I am new to CSharp. Somebody please tell me how to select the entire row in
a data grid on a mouse click event on any of the cell.

Thanx in advance
Dhannu

Nov 16 '05 #3

P: n/a

Dhanraj K wrote:
Hello All,

I am new to CSharp. Somebody please tell me how to select the entire row in a data grid on a mouse click event on any of the cell.

Thanx in advance
Dhannu


On the mouse up event you can do try this:

DataGrid.HitTestInfo htiHitTest = yourDataGrid.HitTest(e.X, e.Y);
if (htiHitTest.Type == DataGrid.HitTestType.Cell)
{
yourDataGrid.Select(yourDataGrid.CurrentRowIndex);
}

Replace [yourDataGrid] with the name of your datagrid.

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.