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

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


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

P: n/a

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

P: n/a

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.