473,239 Members | 1,453 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,239 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 15406
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 =...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.