Tab Control not firing system events - c#

This is for WinForms.
I am having a strange problem that is driving me absolutely batty. I have a tab control for which standard system events, and only standard system events, are not firing. The specific event I was trying to get to fire was the TabIndexChanged event. It doesn't matter whether I add this programmatically or with the designer.
Note: Mouse events will fire. Keypress events will fire. All other events that I have tried will fire.
System events on OTHER controls will fire.
It isn't a single tab control that is having a problem either. If I drag a new tab control onto the form it will also have this problem.
I do not really have any code to show here because it would just be the event as generated by the designer and a Console.WriteLine message to see if it is firing (this line outputs for other events). What I am hoping for is some insight as to what could cause this problem.
The entire program is quite large, so I cannot really clip the whole thing into this forum so that individuals can hunt for a specific problem. My hope is that somebody might be able to point me to what might cause this behavior. I am thinking that maybe something got screwed up when editing in design mode, but I just do not know what to look for. I am relatively new to C# and programming is a hobby for me.
Thank you for your time,
FC

You need to try the property SelectedIndexChanged; to expose that property, with the property window open, click once outside the tabbed container then click one of the small tabs once, don't click inside the tab area. Find the property, type in an event name and then double click it.

Related

C#/.NET - View a list of system events ie. Windows that have been displayed, buttons that have been clicked etc

I'm completely new to C# and the .NET framework so forgive me if this is a silly question.
Is there any way of viewing a list of all of the events that have happened on a Windows system as a result of keystrokes and mouse movements etc.? So for example when I click on the Start menu, the Start menu is displayed or when I click the "Apply" button within a settings sub-menu, the settings are applied.
Is there any part of the .NET framework that will allow me to view all of these events/actions and record them via a C# program? Any help would me greatly appreciated! Thanks in advance.
UI Automation API is what you need. For listening automation events there are few kinds of handlers: AutomationEventHandler, StructureChangedEventHandler and 2 others.
There is another way for native windows: global mouse and keyboard hooks. See SetWindowsHookEx function.
C# in visual studio designer gives you the ability to respond to all kinds of events, like mouse moves and clicks. If you click on the object you want events from, then go to the events pane, you will see a list of all the events for that object. double click in the textbox next to it and it will auto-generate an event handler in your code. When the event is triggered, it will go to this method and do any code you provide there; IE log the action however you choose.

Menu open event

I have a WPF menu which I add items to programatically. It consist of a couple of MenuItems. However, in one of the menuitems I add a ListBox.(I needed a scroller because we have many items and that made it easy).
The menu looks fine and works. The problem is that after I select (click on) something on the ListBox the menu closes as expected; but if I move the mouse over it, the menu pops open. I have searched all over the internet with no luck which is not surprising since it is pretty custom stuff.
The last thing I tried was checking the events and see if I can handle them. I can detect the MouseOver. However I do not see any PopOpen or OnClick event for the menu.
Any ideas if I can detect these events? Any other ideas, suggestions would be appreciated. And if there is a way to add a scroller to a bunch of MenuItems then I may change my design as well.

Listview Focus Issues with Remote Desktop in C#

I am dealing with a problem reported in my company's scheduling application written in C#. We have a list of events in a Listview on the right of the scheduling grid, and you can scroll through that list and drag and drop events onto the grid. This works great in XP, Vista, 7, etc -- but not when you're using remote desktop. When using remote desktop, you have to double-click the event so you can drag it onto the grid, even though the RD and the application have focus, as well as the Listview.
My boss told me that remote desktop just doesn't work well for a drag and drop operation, but I haven't really been able to find any proof of that. I've tried a variety of ways to solve this problem, including resetting the focus &/or selections, adding an extra call to the click event, and nothing has worked. I have DragLeave, MouseMove, MouseDown, and MouseUp events to play around with. The code does register the MouseMoves just fine... it just seems to swallow that first click. Has anyone experienced anything like this? Any ideas?
Have you checked that the control loses focus when using it remotely ?
Did you try something like the code below ?
public override void OnMouseEnter(MouseEventArgs e)
{
this.Focus();
}

WPF UI Automation - Control Tree not poluated till region is clicked for a TabControl

I am doing a UI automation for a WPF application using the Microsoft UI Automation library and it works well.
However my app has four screens in a TabControl. Even when I click the tab item through code its child control tree isnt populated. The only control I can see is the "thumb" Control. Same happens when I see the control tree with UISpy.
However if the window is clicked then all the controls appear. As a Workaround I am simulating a mouseclick through code and it works. I wanted to know if there is some better way of doing it.
I ran into a problem similar to this. What was happening was some data was being retrieved on threads and the controls were not generated at the point automation peers were generated. I would suggest if you have access to the code base for the application you are attempting to automate looking into whether threading is being used. In my specific case it was because BeginInvokes were used to retrieve the data, I switched them to Invokes and it worked fine.
Also from what I could tell the reason the controls were being show on mouse over was because the tool tip generated a popup and caused the automation peers to be updated.
Why don't you click the control using mouse events if that is what works.
(Now, if you still are having that problem..)
How to simulate Mouse Click in C#?

Gain Access to Mouse Clicks in C# Component

I am using the ScintillaNET component and I am attempting to capture clicks in the margin, as this will determine how I respond. Unfortunately, the margins capture the mouse events (and don't provide a way, from what I can see, to get the click information - number of clicks, mouse button clicked, etc).
If this is indeed the case (I am not able to get that info directly), what is another way of capturing what the mouse is doing before the MarginClick event is fired?
Thanks for any help!
I did not figure out a solution to my specific question. Instead, I changed my code to look at the modifier keys that are pressed when the MarginClick event is fired. This solution works well, and I am going to accept this answer. However, if someone can specifically answer my question, I will accept that answer.

Categories