PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?ZGVubmlzdDY4NQ==?=
Guest
Posts: n/a
 
      16th Jul 2005
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

 
Reply With Quote
 
 
 
 
ÈÎÔ¶[΢Èí]
Guest
Posts: n/a
 
      18th Jul 2005
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]

 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      19th Jul 2005
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."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DatagridView modify individual Column Header cells =?Utf-8?B?TWFydHk=?= Microsoft Dot NET Framework Forms 4 6th Jul 2006 07:37 AM
Reordering individual rows in a DataGridView? John Microsoft C# .NET 1 6th Jun 2006 03:10 PM
DatagridView, setting Font for individual Cells Martin Streller Microsoft ADO .NET 1 12th Oct 2004 06:59 PM
Individual CheckBox Web Controls ..HELP =?Utf-8?B?YmVib3A=?= Microsoft Dot NET 0 16th Feb 2004 09:26 PM
Individual CheckBox Web Controls ..HELP =?Utf-8?B?YmVib3A=?= Microsoft Dot NET 0 16th Feb 2004 09:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:31 PM.