By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,957 Members | 1,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,957 IT Pros & Developers. It's quick & easy.

Moving to a field in a grid

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.
--------------------From: "Woody Splawn" <wo***@splawns.com>
Subject: Moving to a field in a grid
Date: Tue, 21 Oct 2003 08:26:18 -0700
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <e6**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148687
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I have a grid with, lets say, 3 fields in it, Debit, Credit and Comments, inthat 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 havecode 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 conceptof 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.


Nov 20 '05 #2

P: n/a
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.
dg_AR.ActiveCell = dg_AR.ActiveRow.Cells("Comments")

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.


Nov 20 '05 #3

P: n/a
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.
--------------------From: "Woody Splawn" <wo***@splawns.com>
References: <e6**************@TK2MSFTNGP09.phx.gbl> <zI*************@cpmsftngxa06.phx.gbl>Subject: Re: Moving to a field in a grid
Date: Wed, 22 Oct 2003 17:07:04 -0700
Lines: 24
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uB**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:149302
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

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.
>dg_AR.ActiveCell = dg_AR.ActiveRow.Cells("Comments")

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

itdoes 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.



Nov 20 '05 #4

P: n/a
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.

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.