473,748 Members | 6,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4366
I had something similar with textbox and datagrid on same panel.
I used MouseEnter event to select datagrid

myDataGrid.Sele ct();

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******** ******@TK2MSFTN GP11.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***********@ SPAMsympaticoPL EASE.ca> wrote in message
news:ON******** ******@TK2MSFTN GP12.phx.gbl...
I had something similar with textbox and datagrid on same panel.
I used MouseEnter event to select datagrid

myDataGrid.Sele ct();

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******** ******@TK2MSFTN GP11.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.Sele ct();

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_Select FullRow(DataGri d grid,
System.Windows. Forms.MouseEven tArgs e)
{
System.Drawing. Point pt = new Point(e.X, e.Y);
DataGrid.HitTes tInfo hti = grid.HitTest(pt );

if (hti.Type == DataGrid.HitTes tType.Cell)
{
grid.CurrentCel l = new DataGridCell(ht i.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_Mouse Wheel(ByVal sender As Object,
ByVal e As System.Windows. Forms.MouseEven tArgs)
Handles DataGrid1.Mouse Wheel
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.dataGridCo mponent.MouseWh eel += new
System.Windows. Forms.MouseEven tHandler(this.D ataGrid_MouseWh eel);

....and elsewhere:

private void DataGrid_MouseW heel(object sender,
System.Windows. Forms.MouseEven tArgs 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
3753
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 to handle that 2 function and tell to my control to scroll up or down based on wheel function? Any one have use it already?
1
3430
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 instance, whenever a user uses the mouse wheel to scroll down, the first record disappears off the screen and they can't get it back unless they click on the Refresh button or Page Up. The mouse wheel never scroll back up to the first record. ...
6
12141
by: GGerard | last post by:
Hello I have an Access 2000 form with the following properties: Record Source - Table1
1
3107
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
3166
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 clicking on the PictureBox objects will get that scrolling working. However, after I click on outside of the PictureBox object, then click as many times as I like on the PictureBox the scrolling with the mouse wheel continues to work. I found...
1
3333
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 this. So how could I disable the mouse scrolling that dropdownlist. Or how could I disable the mouse-scroll on those pages.
3
2719
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 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). ...
14
13814
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
8591
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 scrollbars. I have found that when a user scrolls the wheel in an attempt to scroll the form down, a combobox or listbox will scroll instead (if it has focus) thus changing the user's original selection. Thanks for any help you can provide! Mark
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.