469,275 Members | 1,835 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Select row of Datagrid, and disable single cell selection.

Hey,
Having somewhat of an issue, I have a datagrid which is giving me issues.
The Datagrid is setup for the user to double click the row, the row is
selected and data within that row populates a form for editing. the problem
is when a user clicks on a cell instead of the whole row, I get an error. My
question is this, is there anyway I can setup the datagrid so when the user
clicks on any cell, the whole row is selected not just that cell. I have set
the datagrid.Readonly=true. Any help would be appreciated.
Thank you,
Terry
Jul 21 '05 #1
4 15161
I converted this on the fly for C# so it hasn't been tested. Put this into
your mouseup or mousedown event on the datagrid. You may also want to test
for hits on HitTestType.RowHeader. Also think about if they use the arrow
keys to move. You may need to dig deeper to get full functionality but
HitTestInfo is the key.

Dim pt as System.Drawing.Point = new System.Drawing.Point (e.X, e.Y)
dim hit as DataGrid.HitTestInfo= DG.HitTest(pt)
if hit.Type == DataGrid.HitTestType.Cell then
DG.CurrentCell = new DataGridCell(hit.Row, hit.Column)
DG.Select(hit.Row)
End If

Hope this helps.
Chris
"Terry" <Te***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
Hey,
Having somewhat of an issue, I have a datagrid which is giving me issues.
The Datagrid is setup for the user to double click the row, the row is
selected and data within that row populates a form for editing. the
problem
is when a user clicks on a cell instead of the whole row, I get an error.
My
question is this, is there anyway I can setup the datagrid so when the
user
clicks on any cell, the whole row is selected not just that cell. I have
set
the datagrid.Readonly=true. Any help would be appreciated.
Thank you,
Terry

Jul 21 '05 #2
Chris,
Thank you for responding!
I will give this a try

Thanks again,
Terry

"Chris, Master of All Things Insignifican" wrote:
I converted this on the fly for C# so it hasn't been tested. Put this into
your mouseup or mousedown event on the datagrid. You may also want to test
for hits on HitTestType.RowHeader. Also think about if they use the arrow
keys to move. You may need to dig deeper to get full functionality but
HitTestInfo is the key.

Dim pt as System.Drawing.Point = new System.Drawing.Point (e.X, e.Y)
dim hit as DataGrid.HitTestInfo= DG.HitTest(pt)
if hit.Type == DataGrid.HitTestType.Cell then
DG.CurrentCell = new DataGridCell(hit.Row, hit.Column)
DG.Select(hit.Row)
End If

Hope this helps.
Chris
"Terry" <Te***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
Hey,
Having somewhat of an issue, I have a datagrid which is giving me issues.
The Datagrid is setup for the user to double click the row, the row is
selected and data within that row populates a form for editing. the
problem
is when a user clicks on a cell instead of the whole row, I get an error.
My
question is this, is there anyway I can setup the datagrid so when the
user
clicks on any cell, the whole row is selected not just that cell. I have
set
the datagrid.Readonly=true. Any help would be appreciated.
Thank you,
Terry


Jul 21 '05 #3
Chris,
Transformed this to C# and this worked! As we say here in our IT
Department, "Your The Best!"
Thanks again!
Terry
c# version:
System.Drawing.Point pt = new System.Drawing.Point (e.X,e.Y);
DataGrid.HitTestInfo hit = dgClientRequest.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
dgClientRequest.CurrentCell = new DataGridCell(hit.Row, hit.Column);
dgClientRequest.Select(hit.Row);
}
"Chris, Master of All Things Insignifican" wrote:
I converted this on the fly for C# so it hasn't been tested. Put this into
your mouseup or mousedown event on the datagrid. You may also want to test
for hits on HitTestType.RowHeader. Also think about if they use the arrow
keys to move. You may need to dig deeper to get full functionality but
HitTestInfo is the key.

Dim pt as System.Drawing.Point = new System.Drawing.Point (e.X, e.Y)
dim hit as DataGrid.HitTestInfo= DG.HitTest(pt)
if hit.Type == DataGrid.HitTestType.Cell then
DG.CurrentCell = new DataGridCell(hit.Row, hit.Column)
DG.Select(hit.Row)
End If

Hope this helps.
Chris
"Terry" <Te***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
Hey,
Having somewhat of an issue, I have a datagrid which is giving me issues.
The Datagrid is setup for the user to double click the row, the row is
selected and data within that row populates a form for editing. the
problem
is when a user clicks on a cell instead of the whole row, I get an error.
My
question is this, is there anyway I can setup the datagrid so when the
user
clicks on any cell, the whole row is selected not just that cell. I have
set
the datagrid.Readonly=true. Any help would be appreciated.
Thank you,
Terry


Jul 21 '05 #4
LOL, I transformed it out of C# to post it. I'm so use to posting in the VB
group I thought I had to get it into VB for you. At least you got it
working. Do you need to make this work with the Arrow Keys? I was thinking
about it more and might have an easy way to do it.

Chris

"Terry" <Te***@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
Chris,
Transformed this to C# and this worked! As we say here in our IT
Department, "Your The Best!"
Thanks again!
Terry
c# version:
System.Drawing.Point pt = new System.Drawing.Point (e.X,e.Y);
DataGrid.HitTestInfo hit = dgClientRequest.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
dgClientRequest.CurrentCell = new DataGridCell(hit.Row, hit.Column);
dgClientRequest.Select(hit.Row);
}
"Chris, Master of All Things Insignifican" wrote:
I converted this on the fly for C# so it hasn't been tested. Put this
into
your mouseup or mousedown event on the datagrid. You may also want to
test
for hits on HitTestType.RowHeader. Also think about if they use the
arrow
keys to move. You may need to dig deeper to get full functionality but
HitTestInfo is the key.

Dim pt as System.Drawing.Point = new System.Drawing.Point (e.X, e.Y)
dim hit as DataGrid.HitTestInfo= DG.HitTest(pt)
if hit.Type == DataGrid.HitTestType.Cell then
DG.CurrentCell = new DataGridCell(hit.Row, hit.Column)
DG.Select(hit.Row)
End If

Hope this helps.
Chris
"Terry" <Te***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
> Hey,
> Having somewhat of an issue, I have a datagrid which is giving me
> issues.
> The Datagrid is setup for the user to double click the row, the row is
> selected and data within that row populates a form for editing. the
> problem
> is when a user clicks on a cell instead of the whole row, I get an
> error.
> My
> question is this, is there anyway I can setup the datagrid so when the
> user
> clicks on any cell, the whole row is selected not just that cell. I
> have
> set
> the datagrid.Readonly=true. Any help would be appreciated.
> Thank you,
> Terry
>
>


Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Chris Plowman | last post: by
1 post views Thread by selen | last post: by
1 post views Thread by PawelR | last post: by
2 posts views Thread by news | last post: by
reply views Thread by =?Utf-8?B?Q2hyaXNK?= | last post: by
4 posts views Thread by =?Utf-8?B?UGFycm90?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.