Getting precise focused element in c# [duplicate] - c#

This question already has answers here:
How do I find out which control has focus in .NET Windows Forms?
(7 answers)
Closed 6 years ago.
I'm having trouble figuring out how to get c# to get the focused element within a window. I've a window of another program with two text boxes, a dropdown, and two buttons. I need to be able to open this program, pull it to the front, and fill in the two text boxes and select from the dropdown programatically.
I can pull the window forward with SetForegroundWindow and fill things out and navigate about with SendKeys, but since I don't always know which box the cursor will start in, I need to be able to determine where it is once I've pulled it to the front to fill them in properly.
Any ideas?

Going off of memory and pseudocode here.
Inside of a form, you should be able to use this.ActiveControl to get that information, which should provide you with a wealth of other information, such as the name of the control, type, etc.

Related

Is it possible to programmatically make an optical click? [duplicate]

This question already has an answer here:
Winforms Button Right-Click visual feedback (Show button in pushed state)
(1 answer)
Closed 5 years ago.
I'Ve got a winform application where specific Buttons should be visibly pressed whenever a specific key is pressed.
Capturing the key is not so much a Problem, but I did not find a method that allowed me to make it visible that a specific button as been "pressed".
(Even with button1.PerformClick() there was no visualization of the "click").
Is there any way to accomplish this?
You can use Control.Select() to activate the control.

How to hide a page from tab control c# [duplicate]

This question already has answers here:
Hiding and Showing TabPages in tabControl
(21 answers)
Closed 6 years ago.
I'm programming a windows application program, using winforms c#
I have a tab control that contains so many pages I need to hide some of these tabs from non-admin users,
for example
if user is an admin no pages will be hided, else page number 1 and 2 will be hided and other pages will be shown,
I don't want to remove pages, just hide because in the program I made you can sign out without closing the program and sign in again as an admin
Please have a look at this thread.
As amazedsaint said:
Visiblity property has not been implemented on the Tabpages, and there is no Insert method also.
You need to manually insert and remove tab pages.
Here is a work around for the same.
http://www.dotnetspider.com/resources/18344-Hiding-Showing-Tabpages-Tabcontrol.aspx
No way to hide it ,you will have to remove pages an re add them for admin user
tabControl.TabPages.Remove(tabPage);
tabControl.TabPages.Add(tabPage);
As seen here you can however disable/enable tabs. While this won't make then invisible, you can restrict access. That should get you going in a workable direction.
I'd personally also put all the restricted tabs at the end, but that's just a point of personal taste.

Easy way to create MessageBox with "custom button" [duplicate]

This question already has answers here:
Custom button captions in .NET messagebox?
(8 answers)
Closed 9 years ago.
I've a winform application, and we are trying to make it ergonomic as possible, so we respect a lot microsoft guidelines.
We have some "Deletion confirmation" to implement, and according the guidelines and what I found accross the web, the more adequate buttons would be:
Delete and Cancel
But since we use the MessageBoxButtons to specify which buttons we have to display, I can't see how we can do this except implementing ourself a confirmation dialog.
I don't find very logical that microsoft encourage in one side the use of "action" text on button, and the other side doesn't give us the tools to be compliant, so I think I'm missing something?
Please note that I don't need more results possibility than currently, My Delete option would be the same as Ok for me, I just want to have differents texts.
So: Is there a way to specify easily buttons we want to show different text here?
There is no easy way other than creating your own implementation using form and show it as dialog?
We did the same some time back because of localization specialities in our project.

How do you make a program with multiple "Pages"? [duplicate]

This question already has answers here:
Creating Wizards for Windows Forms in C#
(3 answers)
Closed 9 years ago.
How do you make something like the things where you install programs by clicking the "Next" button and it will show you like a TextBox instead of a ComboBox like on a new Panel?
Sort of like changing Tabs on a TabControl but without showing the tabs.
You are probably looking for Wizard. You may see
Simple Wizard for Winforms - CodeProject
You may also take a look at WinForms Wizard from DevExpress but its not free.

Make controls disappear sidely [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I add moving effects to my controls in C#?
I'm work on on a C# WinForms project, and I created a login form.
I want when I click in a link in this login form to make the controls in the login form to disappear sidely (like the effect in iPad when you move your finger on it) and other controls to be appeared .
Is there any chance to make this possible (using WinForm)?
Check DevExpress slider controls for Windows Forms.
You should find some examples here :
http://www.devexpress.com/Products/NET/Controls/WinForms/index.xml
http://www.devexpress.com/Products/NET/Controls/WinForms/Bars/toolbar_menu.xml (slide menu effecT)

Categories

Resources