Moving to a field in a grid

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

I have a grid with, lets say, 3 fields in it, Debit, Credit and Comments, in
that order. When the user moves to the debit field, if he enters data in
it, I would like for the cursor to skip past the Credit field to the
comments field. I have a ColumnChanging event where I trap to see what
field the user is on. I trap for the user being on the Debit field. I have
code that , in my mind should cause the cursor to move to the Comments
field, but it is not working. The line looks like this:

dg_AR.ActiveCell = dg_AR.ActiveRow.Cells("Comments")

The syntax here is indegineous to Infragistics but if you will not tune me
out, I think the question is best answered here. Actually, the cusor does
move to the Comments field. I know this because although it is very quick,
if I look closely I actually see it happen, the problem is that after it
moves to the Comments field, it then moves to the field it would ordinarily
move to - the credit field.

I think I understand what is happening but don't know how to solve it. In
the environment I came from prior to VS (PowerBuilder) there was the concept
of a Post event. If you have an event you want to fire and you make it a
Post event, it is gauranteed to run at the end of everything else, i.e,
after all other internal events fire. I think this is why my code isn't
working in VS. Something is firing after my call for an explicit move. I
think I remember seeing the equivelent of a Post event in VS but I can not
find a reference to it in my notes. If there is such a thing could someone
point me to it and tell me how to use it?

If someone can see that solution lies elsewhere could you point me to that?

Thank you.
 
Hi Woody,

What do you mean by grid?
Is it a Datagrid control in VB.NET in a winform application.
Based on my understanding, what you want to do is when you hit Tab key in
column 0,i.e. fields 1 in your words, the cursor will move to the column 2,
i.e. fields 3.
Did I misunderstand your meaning?
If you have any related question, please post here.

Here I write some code for you.

You can handle the CurrentCellChanged event.
To let the mouse select the column 1, i.e. the second field, set the flag
variable.

Dim flag As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
flag = False
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
If DataGrid1.CurrentCell.ColumnNumber = 1 Then
If flag Then
flag = False
Else
DataGrid1.CurrentCell = New
DataGridCell(DataGrid1.CurrentCell.RowNumber, 2)
End If
End If
End Sub
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
Dim ht As DataGrid.HitTestInfo = DataGrid1.HitTest(e.X, e.Y)
If ht.Column = 1 Then
flag = True
Else
flag = False
End If
End Sub
dg_AR.ActiveCell = dg_AR.ActiveRow.Cells("Comments")
what is the dg_AR object, is it a datagrid?



Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 
Thanks for responding Peter
What do you mean by grid?
Is it a Datagrid control in VB.NET in a winform application.

Yes it is a datagrid. Specifically a Infragistics UltraGrid.
what is the dg_AR object, is it a datagrid?

Yes Dg_AR is the name of the datagrid.

I think you have the idea of what I am trying to do. However, because this
is a UltraGrid, it does not have a CurrentCellChanged Event. But whether it
does or not my main question is this:

Is it possible to call a subroutine in a way that will cause it (the sub
routine) to fire after all other built-in Visual Studio events have fired?
I thought I remembered reading that you could do this in VS but I don't
remember where I saw it or how to implement it if it exists.
 
Hi Woody,
I think you have the idea of what I am trying to do. However, because this
is a UltraGrid, it does not have a CurrentCellChanged Event. But whether
it
It seems that the UltraGrid has the AfterCellActivate event, you may trap
it and handle the event to achieve your aim.
does or not my main question is this:

Is it possible to call a subroutine in a way that will cause it (the sub
routine) to fire after all other built-in Visual Studio events have fired?
I thought I remembered reading that you could do this in VS but I don't
remember where I saw it or how to implement it if it exists.
I think there is no such method in .NET

If you have any related question, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 
Hi Woody,

If you have any question on this issue please post here.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top