473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Mouse Wheel Scrolling Causes DataGrid To Loose Focus

Hi All

I got a datagrid and a ComboBox on a form. I populate the combobox with
years for all the data avaiable. When the user chooses a year the datagrid
is populated with the specific years information.

Problem... when the users scrolls the datagrid with the mouse wheel it work
for 2 wheel clicks and then for some reason the focus jumps to the combobox
and the year is then changes there for causing the data to change and errors
.... sometimes.

Anybody experience this or know how to fix it...

Thanks
Bryan
Nov 15 '05 #1
5 4318
I had something similar with textbox and datagrid on same panel.
I used MouseEnter event to select datagrid

myDataGrid.Select();

For me it did the trick. How's it for you?

Note, that I was updating content of grid on mouse wheel. It might've been
related to dynamic change of data there.

HTH
Alex

"Bryan Masephol" <ma******@uwec.edu> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi All

I got a datagrid and a ComboBox on a form. I populate the combobox with
years for all the data avaiable. When the user chooses a year the datagrid is populated with the specific years information.

Problem... when the users scrolls the datagrid with the mouse wheel it work for 2 wheel clicks and then for some reason the focus jumps to the combobox and the year is then changes there for causing the data to change and errors ... sometimes.

Anybody experience this or know how to fix it...

Thanks
Bryan

Nov 15 '05 #2
Hmmm

Thanks for the input Alex but it seemed to make things worse. Even though I
select the datagrid when the mouse enters it still wants to jump to my
combobox. Very weird. I'll keep trying things and post what I find.

If anyone else had problems like this please contribute.

Bryan

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:ON**************@TK2MSFTNGP12.phx.gbl...
I had something similar with textbox and datagrid on same panel.
I used MouseEnter event to select datagrid

myDataGrid.Select();

For me it did the trick. How's it for you?

Note, that I was updating content of grid on mouse wheel. It might've been
related to dynamic change of data there.

HTH
Alex

"Bryan Masephol" <ma******@uwec.edu> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi All

I got a datagrid and a ComboBox on a form. I populate the combobox with
years for all the data avaiable. When the user chooses a year the

datagrid
is populated with the specific years information.

Problem... when the users scrolls the datagrid with the mouse wheel it

work
for 2 wheel clicks and then for some reason the focus jumps to the

combobox
and the year is then changes there for causing the data to change and

errors
... sometimes.

Anybody experience this or know how to fix it...

Thanks
Bryan


Nov 15 '05 #3
I normally wouldn't reply to posts this old, but they seem really
similar
to what I'm working on...

"Bryan Masephol" <ma******@uwec.edu> wrote:
I got a datagrid and a ComboBox on a form. I populate the combobox
with years for all the data avaiable. When the user chooses a year
the datagrid is populated with the specific years information.

Problem... when the users scrolls the datagrid with the mouse wheel
it work for 2 wheel clicks and then for some reason the focus jumps
to the combobox and the year is then changes there for causing the
data to change and errors ... sometimes.
I have a similar setup, though I have TWO datagrids. If I click in
the bottom grid, then just like happened to Bryan, after 2 wheel
clicks the focus shifts to the ComboBox. If I click in the top grid,
then after 2 clicks, focus moves to the lower grid, then to the
ComboBox on the next click.

AlexS replied to Bryan: I had something similar with textbox and datagrid on same panel.
I used MouseEnter event to select datagrid

myDataGrid.Select();

For me it did the trick. How's it for you?


It's unclear what component's event I'm supposed to do that on, but
doing it on the grid does squat for me.

AlexS later suggested that perhaps Bryan had a DataSource being
shared between the ComboBox and DataGrid, but that doesn't seem to
be the case in my application (the ComboBox always gets a new
DataSource). But it wasn't clear if AlexS meant literally the
DataSouce component or a more general "data source" and possibly
therefore meaning something else...
Does anyone else have any (other) ideas/solutions?

Nov 16 '05 #4
I wrote:
"Bryan Masephol" <masep...@uwec.edu> wrote:
I got a datagrid and a ComboBox on a form. I populate the combobox
with years for all the data avaiable. When the user chooses a year
the datagrid is populated with the specific years information.

Problem... when the users scrolls the datagrid with the mouse wheel
it work for 2 wheel clicks and then for some reason the focus jumps
to the combobox and the year is then changes there for causing the
data to change and errors ... sometimes.
I have a similar setup, though I have TWO datagrids. If I click in
the bottom grid, then just like happened to Bryan, after 2 wheel
clicks the focus shifts to the ComboBox. If I click in the top grid,
then after 2 clicks, focus moves to the lower grid, then to the
ComboBox on the next click.


I hate following up my own posts, but I just noticed something --
it's not "2 wheel clicks" before it changes focus, but rather it's
when the selected row scrolls out of the "viewport".

Also, it's changing focus to the next component in TabOrder; I set
TabStop to false for the two DataGrids and the ComboBox and now
focus jumps to a TextBox (which I'd like to keep tab-able along
with the other components around it) when the selected row scrolls
out of the DataGrid's viewable area.

I have some code to select the whole row instead of just the cell
clicked in, as shown below -- is there maybe something to this
that's screwing things up? I don't think so, since I commented
that out of the DataGrids' MouseUp events, but who knows.

Any ideas?

private void DataGrid_SelectFullRow(DataGrid grid,
System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = grid.HitTest(pt);

if (hti.Type == DataGrid.HitTestType.Cell)
{
grid.CurrentCell = new DataGridCell(hti.Row, hti.Column);
grid.Select(hti.Row);
}
}

Nov 16 '05 #5
Solved... For posterity:

I wrote:
"Bryan Masephol" <masep...@uwec.edu> wrote:
I got a datagrid and a ComboBox on a form. I populate the combobox
with years for all the data avaiable. When the user chooses a year
the datagrid is populated with the specific years information.

Problem... when the users scrolls the datagrid with the mouse wheel
it work for 2 wheel clicks and then for some reason the focus jumps
to the combobox and the year is then changes there for causing the
data to change and errors ... sometimes.
it's not "2 wheel clicks" before it changes focus, but rather it's
when the selected row scrolls out of the "viewport".
After two days, I finally managed to come up with the right search
criteria to find an answer...

From: http://www.dotnetforums.net/t78467.html
Private Sub DataGrid1_MouseWheel(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles DataGrid1.MouseWheel
DataGrid1.Focus()
End Sub


I'm using C#, but the idea was clear enough, and I got it working.

....Though Visual Studio (7.1.3088 with .Net 1.1.4322) doesn't seem
to give me the MouseWheel event in the visual builder, so I had to
add it manually to the "Windows Form Designer generated code",
which always makes me a little nervous since it says "do not modify
the contents of this method with the code editor". I don't know if
Visual Studio is set up incorrectly, or if later versions list this
event, or what, but ugh...

In that section:

this.dataGridComponent.MouseWheel += new
System.Windows.Forms.MouseEventHandler(this.DataGr id_MouseWheel);

....and elsewhere:

private void DataGrid_MouseWheel(object sender,
System.Windows.Forms.MouseEventArgs e)
{
((DataGrid) sender).Focus();
}

....and no scrolling with the mouse wheel works.

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: serge calderara | last post by:
Dear all, I would like to be able to use the mouse wheel button in my windows application to scroll my control data. The weel gets two function, when you rotate it and whne you press it. How...
1
by: jv | last post by:
I have quite a few of continuous form and subform where I do allow scroll bars. I run into problems with the mouse wheel whenever the data on the form does not take up the whole page. In this...
6
by: GGerard | last post by:
Hello I have an Access 2000 form with the following properties: Record Source - Table1
1
by: Marcin | last post by:
Im using MS Access 2000. i have a main form and ona subform that is scrolled vertically. unfortunately i use mouse scroll to scroll this subform. I appreciate your help
0
by: 6tc1 | last post by:
Hi all, I've got a UserControl that contains a few PictureBox objects. If I click on outside of the Picture in the UserControl, the scrolling with the mouse button works - however, no amount of...
1
by: nicholas | last post by:
Hi, If on an asp.net page the user has just selected a value in a dropdownlist and scrolls with the wheel of his mouse, the selected value of the dropdownlist will change. How could I avoid...
3
by: Brian Tkatch | last post by:
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...
14
by: effendi | last post by:
Is it possible for me to disable the wheel scroll in a mouse when user click on a drop-down list? Thanks
2
by: =?Utf-8?B?TWFyaw==?= | last post by:
Does anyone know of a way to disable the mouse scroll wheel when a control such as a combobox or listbox has focus? I ask this, because I have an extremely large data entry form with vertical...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.