469,600 Members | 2,230 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,600 developers. It's quick & easy.

Scrolling DataGrid's selected row out of view selects next control

I have a form with two DataGrids, which are kept in sync manually via
Stored PROCEDURE calls. That is, when a record is selected on the first
grid, a stored PROCEDURE is CALLed to Fill() the next second DataGrid's
DataSource. All that works very well. And, when there are no records to
display, it is simply left blank.

My issue is that when i scroll the first one, sometimes the second grid
shows a bunch of null values (a "new" record).

After a little study, i realized the problem happens when there are no
records to show in the second grid, and the first grid is scrolled so
that the currently selected row (as indictated by Black Right-Pointing
Pointer (as Charmap calls it)) goes off the screen. This causes the
second grid to be automatically selected (as the now showing Black
Right-Pointing Pointer indicates) but because there are no records, it
starts a new one.

This is the same issue as having a blank DataGrid as the first control
in a Form's TabIndex. It will start a new record immediately.

The question is, how do i prevent this from happening? Starting a new
record needs to be possible manually, it should just not be started
automatically. And i would like the keep eacdh grid as a TabStop, and
lkeep the current order of TabIndexing.

B.

Jul 7 '06 #1
3 2529
Brian,

This might work for you:

http://www.syncfusion.com/FAQ/Window...44c.aspx#q653q

Kerry Moorman
"Brian Tkatch" wrote:
I have a form with two DataGrids, which are kept in sync manually via
Stored PROCEDURE calls. That is, when a record is selected on the first
grid, a stored PROCEDURE is CALLed to Fill() the next second DataGrid's
DataSource. All that works very well. And, when there are no records to
display, it is simply left blank.

My issue is that when i scroll the first one, sometimes the second grid
shows a bunch of null values (a "new" record).

After a little study, i realized the problem happens when there are no
records to show in the second grid, and the first grid is scrolled so
that the currently selected row (as indictated by Black Right-Pointing
Pointer (as Charmap calls it)) goes off the screen. This causes the
second grid to be automatically selected (as the now showing Black
Right-Pointing Pointer indicates) but because there are no records, it
starts a new one.

This is the same issue as having a blank DataGrid as the first control
in a Form's TabIndex. It will start a new record immediately.

The question is, how do i prevent this from happening? Starting a new
record needs to be possible manually, it should just not be started
automatically. And i would like the keep eacdh grid as a TabStop, and
lkeep the current order of TabIndexing.

B.

Jul 7 '06 #2

Kerry Moorman wrote:
Brian,

This might work for you:

http://www.syncfusion.com/FAQ/Window...44c.aspx#q653q

Kerry Moorman
"Brian Tkatch" wrote:
I have a form with two DataGrids, which are kept in sync manually via
Stored PROCEDURE calls. That is, when a record is selected on the first
grid, a stored PROCEDURE is CALLed to Fill() the next second DataGrid's
DataSource. All that works very well. And, when there are no records to
display, it is simply left blank.

My issue is that when i scroll the first one, sometimes the second grid
shows a bunch of null values (a "new" record).

After a little study, i realized the problem happens when there are no
records to show in the second grid, and the first grid is scrolled so
that the currently selected row (as indictated by Black Right-Pointing
Pointer (as Charmap calls it)) goes off the screen. This causes the
second grid to be automatically selected (as the now showing Black
Right-Pointing Pointer indicates) but because there are no records, it
starts a new one.

This is the same issue as having a blank DataGrid as the first control
in a Form's TabIndex. It will start a new record immediately.

The question is, how do i prevent this from happening? Starting a new
record needs to be possible manually, it should just not be started
automatically. And i would like the keep eacdh grid as a TabStop, and
lkeep the current order of TabIndexing.

B.
Much appreciated.

That actually was not what i wanted. But it got me thinking. :)

Since the scroll is making the first grid to lose focus....

In the scroll even of the DataGrid i added "sender.Select()". This
returns focus to the DataGrid which removes the "new" record from the
following grid.

Unfortunately, the other DataGrid does get Focus for a second and the
nulls are sometimes seen.

B.

Jul 7 '06 #3

Brian Tkatch wrote:
Kerry Moorman wrote:
Brian,

This might work for you:

http://www.syncfusion.com/FAQ/Window...44c.aspx#q653q

Kerry Moorman
"Brian Tkatch" wrote:
I have a form with two DataGrids, which are kept in sync manually via
Stored PROCEDURE calls. That is, when a record is selected on the first
grid, a stored PROCEDURE is CALLed to Fill() the next second DataGrid's
DataSource. All that works very well. And, when there are no records to
display, it is simply left blank.
>
My issue is that when i scroll the first one, sometimes the second grid
shows a bunch of null values (a "new" record).
>
After a little study, i realized the problem happens when there are no
records to show in the second grid, and the first grid is scrolled so
that the currently selected row (as indictated by Black Right-Pointing
Pointer (as Charmap calls it)) goes off the screen. This causes the
second grid to be automatically selected (as the now showing Black
Right-Pointing Pointer indicates) but because there are no records, it
starts a new one.
>
This is the same issue as having a blank DataGrid as the first control
in a Form's TabIndex. It will start a new record immediately.
>
The question is, how do i prevent this from happening? Starting a new
record needs to be possible manually, it should just not be started
automatically. And i would like the keep eacdh grid as a TabStop, and
lkeep the current order of TabIndexing.
>
B.
>
>

Much appreciated.

That actually was not what i wanted. But it got me thinking. :)

Since the scroll is making the first grid to lose focus....

In the scroll even of the DataGrid i added "sender.Select()". This
returns focus to the DataGrid which removes the "new" record from the
following grid.

Unfortunately, the other DataGrid does get Focus for a second and the
nulls are sometimes seen.

B.
OK, i think i got what i wanted.

1) Add a class-wide boolean variable:

Dim Scrolling As Boolean

2) In the Scroll event of the DataGrid set it:

Scrolling = True

3) In the Validating event of the DataGrid, if it is set, unset it and
cancel the event.

If Scrolling Then
Scrolling = False
e.Cancel = True
End If

The only issue right now, is that if the first thing done when it comes
up is a scroll (that is, the user scroll before effecting any other
event), it still shows the null record the first time it is passed
(even if the user scrolls many times).

B.

Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Lina | last post: by
2 posts views Thread by Chris Plowman | last post: by
5 posts views Thread by Jeff | last post: by
3 posts views Thread by David | last post: by
7 posts views Thread by DJ Dev | last post: by
1 post views Thread by JMann101 | last post: by
6 posts views Thread by Doug Bell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.