473,323 Members | 1,537 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,323 software developers and data experts.

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 15411
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
1
by: selen | last post by:
Hello Can I select the cell in datagrid? and can I read its text. I cant do it asp.net in c#... Thanks
0
by: Pete Davis | last post by:
Sorry to have to post this here, but none of the accessibility newsgroups seem to be active. I've got a custom control that I'm adding accessibility support to. The control is a grid control and...
1
by: PawelR | last post by:
Hello group, In my application, I have form with DataGrid. Rows in dataGrid are from table. myDG.DataSource = myTable; In Table I have collumn boolean type. On Click (Mouse_up event) on...
2
by: news | last post by:
Hello All, As a VB6/C/C++ (and some Java) developer, I've been toying with c# for the last couple of weeks. I'm currently trying to create a grid of 3x3 with each cell containing numbers from 1...
4
by: Terry | last post by:
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...
1
by: Hemant Pathak | last post by:
Hi...........PM i m using Vb.6.0 n Datagrid.when i make the focus on ant cell of the datagrid the cell is automaticlly get selected but i want to remove the selection of the text in the cell by...
0
by: =?Utf-8?B?Q2hyaXNK?= | last post by:
I am using a datagrid as a selection list on a form. There is an OK button which closes the form and returns the current selection. I would like to get a doubleclick to perform the same action...
4
by: =?Utf-8?B?UGFycm90?= | last post by:
I cannot programmatically select a row in datagridview control. I use the following instruction to change the selection of a row dataGridView2.ClearSelection(); dataGridView2.Rows.Selected =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.