Hello,

With the following method I retrieve the value of a specific field in a
DataGrid - it is the Id of the line of the DataGrid - The Problem is that
when I select the Id with the stylo only the the Id is marked and not the
whole line. What do I have to do that the whole line is marked when I select
one Id?

private void dgridDisplay_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{

DataGrid dgridSender = (DataGrid) sender;
DataTable dtabDataSource = (DataTable)dgridSender.DataSource;

DataGridTableStyle dgtsCurrent =
dgridSender.TableStyles[dtabDataSource.TableName];

httstInfo = dgridSender.HitTest(e.X, e.Y);
try
{

string strColumnName =
dgtsCurrent.GridColumnStyles[httstInfo.Column].MappingName;
jobId = dtabDataSource.Rows[httstInfo.Row][strColumnName].ToString();
}
catch(ArgumentOutOfRangeException)
{
MessageBox.Show("Not marking a row header but a Id!");
}
catch(IndexOutOfRangeException)
{
MessageBox.Show("Not marking a column header but a Id!");
}
}

Thanks in Advance.

patrick

Re: DataGrid - selection by Milsnips

Milsnips
Thu Nov 11 06:44:17 CST 2004

try this (sorry its written in vb.net code...):

Private Sub grdProducts_CurrentCellChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles grdProducts.CurrentCellChanged

grdProducts.Select(grdProducts.CurrentCell.RowNumber)

AddProductToOrder()

End Sub



hope it helps,
Paul.


"pat" <pat@discussions.microsoft.com> wrote in message
news:41DC74CA-DFC8-446F-B2D2-FF3023FCD9B9@microsoft.com...
> Hello,
>
> With the following method I retrieve the value of a specific field in a
> DataGrid - it is the Id of the line of the DataGrid - The Problem is that
> when I select the Id with the stylo only the the Id is marked and not the
> whole line. What do I have to do that the whole line is marked when I
select
> one Id?
>
> private void dgridDisplay_MouseMove(object sender,
> System.Windows.Forms.MouseEventArgs e)
> {
>
> DataGrid dgridSender = (DataGrid) sender;
> DataTable dtabDataSource = (DataTable)dgridSender.DataSource;
>
> DataGridTableStyle dgtsCurrent =
> dgridSender.TableStyles[dtabDataSource.TableName];
>
> httstInfo = dgridSender.HitTest(e.X, e.Y);
> try
> {
>
> string strColumnName =
> dgtsCurrent.GridColumnStyles[httstInfo.Column].MappingName;
> jobId = dtabDataSource.Rows[httstInfo.Row][strColumnName].ToString();
> }
> catch(ArgumentOutOfRangeException)
> {
> MessageBox.Show("Not marking a row header but a Id!");
> }
> catch(IndexOutOfRangeException)
> {
> MessageBox.Show("Not marking a column header but a Id!");
> }
> }
>
> Thanks in Advance.
>
> patrick