This question already has answers here:
Uwp navigation example and focusing on control
(2 answers)
Closed 6 years ago.
I have a Universal Windows Platform project that has a textBox element.
I'd like to set the focus to it when a Radio Button is clicked.
In the Radio Button click event, I can say:
txtBoxID.IsEnabled = true;
txtBoxID.Text = "";
But how do I set the focus? I saw some answers saying to use:
FocusManager.SetFocusedElement(
but my FocusManager class doesn't have that method.
edit: Solved, thanks. Just needed to know what argument to pass to SetFocus. The other fellow's question which was thought to be similar was regarding an event occurring after he set focus to his control.
All the code you need is:
txtBoxID.Focus(FocusState.Programmatic);
Method is defined in Control.
Related
This question already has answers here:
Xamarin forms navigation back button
(3 answers)
Closed 3 years ago.
How can I intercept the back button events in xamarin forms for Android and IOS and be able to show the user an alert to confirm the exit?
The objective is to intercept the 2 buttons, the navigation menu (yellow) and the device (orange)
I have seen some examples, but they are several years old.
I am using VS 2019 and the latest version of xamarin forms.
Thank you in advance for your help.
You can Use Title View instead of default navigation bar and handle the back button event. Please refer: https://github.com/xamarin/xamarin-forms-samples/tree/master/Navigation/TitleView
also you can handle device back button event by override it like this:
protected override bool OnBackButtonPressed()
{
//return true to prevent back, return false to just do something before going back.
return true;
}
Hope this may resolve your issue.
This question already has answers here:
How to use PasswordBox as TextBox? [closed]
(4 answers)
Closed 5 years ago.
I am currently making a c# application, in which I am using a text box with property PasswordChar - •. However, this text box has a button like the one below:
However, as a student and amateur, I am unable to make an if code for the button, which when pressed, shows or hides the real numbers of the password.
I think it should be something like this:
private void metroTextBox1_ButtonClick(object sender, EventArgs e)
{
if (metroTextBox1.PasswordChar='\•') metroTextBox1.PasswordChar = '\0';
else metroTextBox1.PasswordChar = '\•';
}
but I think I have at least 1 mistake here.
Please, help!
Your mistakes are in this :
textBox1.PasswordChar = '\•'
You must use == instead of = and '•' instead of '\•'
textBox1.PasswordChar == '•'
It worth be added as #Cody Gray has already noted that it is better to use UseSystemPasswordChar
This question already has answers here:
How can I access one window's control (richtextbox) from another window in wpf?
(4 answers)
Closed 9 years ago.
Alright, so I have a form with textboxes and a button (Form 1), and that button opens a new form (Form 2) consisting of a textbox.
What I want to do is get the contents of one of the textboxes of the first form (like TextboxForm1.Text) and use that text in the second form, like TextboxForm2.Text = {however to reference textbox 1 from form 1}.Text;.
Is there an obvious way that I overlooked?
Thanks.
Edit: Tried both solutions and the both worked well, but making it public was much easier in the case of multiple textboxes.
http://msdn.microsoft.com/en-us/library/aa970905.aspx
<TextBox Name="TextboxForm1" x:FieldModifier="Public" />
Yes, you could use a property to expose the value of the desired textbox from the appropriate form. So, add something like the following to your window class:
public string TextBox1Text {
get { return TextBox1.Text; }
}
And then access it from the instance, as you seem to know, like this:
AnotherTextBox.Text = instance.TextBox1Text;
As for using the access modifier for the control as per nmclean's answer (i.e. FieldModifier="Public"), I would only say make the entire control public if it is needed.
This question already has answers here:
Remove the title bar in Windows Forms
(7 answers)
Closed 9 years ago.
I am actually developing a UserControl that requires this kind of form.
Normally a WinForms Form looks like this:
If I set "FormBorderStyle = None", it looks like this:
But, I actually need a window without TitleBar like the following:
Please see the difference at the edge of the window. It actually looks more like a context menu.
myForm.Text="";
myForm.ControlBox= false;
This solution leaves the TitleBar so that the form remains movable. This is a problem.
I actually need this: the user click the button and the form appears like the following:
How to do this?
you can use:
yourForm.Text="";
yourForm.ControlBox= false;
and in properties, change : FormBorderStyle to :FixedDialog
To get like that then do not set any title text and make controlbox visible false
like this
yourForm.Text="";
yourForm.ControlBox= false;
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
center MessageBox in parent form
I am trying to make an C# application and I want to have my messageBox appear near the parent.
I tried:
MessageBox.Show(this,"this operation does not work");
And this doesn't work.
Assuming you're using Windows Forms, create a new class which extends System.Windows.Form to mimic MessageBox. Set the Location property based on your new classes Parent.Location property.