Can't synchronize individual controls and a datagridview to the sa

G

Guest

Sorry for asking here, but there's been hundreds of views of my question in
the vs 2005 forums, but not a single answer.


Can't synchronize individual controls and a datagridview to the same row.
It was easy to do in vs studio 2003.

When I changed to row in the controls, the row would changed in the datagrid
through the currency manager . I used the code

dgrd.CurrentRowIndex = cm.Position

I tried a similar strategy with 2005 with the following code

dgrd.CurrentRow = KSGroupsBindingSource.Current

The 'CurrentRow' property of the DataGridView 'Gets the row containing the
current cell.' and hence is read only. I couldn't find another member that
was an equivalent.

In the opposite direction, I used the hit test.

Private Sub dgrd_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles dgrd.MouseDown
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Dim iRow As Integer
Select Case hti.Type
Case System.Windows.Forms.DataGrid.HitTestType.Cell,
System.Windows.Forms.DataGrid.HitTestType.RowHeader
iRow = hti.Row
cm.Position = iRow
Case Else
End Select

End Sub

I tried the following with the datagridview:

Private Sub dgrd_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles dgrd.MouseDown
Dim myGrid As DataGridView = CType(sender, DataGridView)
Dim hti As System.Windows.Forms.DataGridView.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Dim iRow As Integer
Select Case hti.Type
Case System.Windows.Forms.DataGridView.HitTestType.Cell,
System.Windows.Forms.DataGridView.HitTestType.RowHeader
iRow = hti.Row
KSGroupsBindingSource.Position = iRow
Case Else
End Select

End Sub

Trouble is with the hittesttype. There is no Cell or RowHeader, only x,y
coordinates. And that's a big job.

Is there a work around for these two problems? It seems a step backward
from vs 2003.


dennist685
 
È

ÈÎÔ¶[΢Èí]

Hi Dennist,

Welcome to MSDN newsgroup!

At the current stage, there is something changed in .NET Framework beta
v2.0. Below comments in the documentation indicates the
DataGridView.CurrentRow property return the value of current cell actually,
so I think we maybe use the DataGridView.CurrentCell property instead:
http://msdn2.microsoft.com/library/ms158653(en-us,vs.80).aspx

I do some research to find some equivalent function now. So thanks for your
patience, and I will come back with more information as soon as possible.

Thanks again!

Yuan Ren[MSFT]
 
K

Kevin Yu [MSFT]

Hi Dennis,

Based on your description, I suggest you check the following:

1. All the controls are binding to the same data source object.
2. Instead of handling the MouseDown event, I suggest you handle the
BindSource.CurrentChanged. It is the substitution for CurrencyManager in
..NET framework 2.0. Please check the following link for more information.

http://msdn2.microsoft.com/library/ms158145(en-us,vs.80).aspx

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top