I'm new to visual studio and I'm developing an application for visually impaired. I'm testing my application with NVDA. The audio feedback I'm getting on moving focus to a TextBox using tab button is just "Edit-Blank". I want to change that to a custom text. How can I do that?
That has nothing to do with accessibility, actually. When developing for accessibility, please always keep in mind the following: a blind (deaf, ...) user must get the same info as all of your users, starting from yourself, unless you absolutely need to convey something that is inaccessible otherwise (a visual tooltip instead of a sound for deaf users, an alternative text description of an image for blind users, etc.).
Here NVDA tells you what you actually get: the edit box is blank, indeed. If you want to describe the box, you need a label, not something in the text box (let the user enter his/her text in it). So:
private Label myLabel;
// ...
this.myLabel = new Label();
// ...
this.myLabel.Text = "Your Name:";
and place that label to the left (or above) the edit box. You may also set AccessibleRole, if you want:
this.myLabel.AccessibleRole = AccessibleRole.StaticText;
I suggest to do this if your form is actually a dialog box.
You need to put a Label control into the form and update the TabIndex properties of the Label and TextBox, so that the Label's TabIndex value is one less than the TextBox's TabIndex value (e.g. label1.TabIndex == 1 and textBox1.TabIndex == 2).
Then, the Text of the Label will be read when entering the TextBox.
To make a TextBox more accessible by NVDA you can perform either of the following settings:
You can set AccessibleName
You can set AccessibleDescription
You can put a Label control near the TextBox having immediate TabIndex before the TextBox.
For Narrator you can perform either of the following settings:
You can set AccessibleName
You can set Cue Banner for the TextBox.
You can put a Label control near the TextBox having immediate TabIndex before the TextBox.
Related
I have seen a lot of answers on the web stating that a Label's text can't be selected/copied in the way that a TextBox's contents can,
but what is the underlying reason that a Label's text can't be copied?
Windows itself can find text under the cursor position, so why can't the WinForm Label control?
In order for a user to select or copy a control's text, the control must allow you to set focus to it, either by clicking or tabing to the control.
A Label doesn't allow this, by design.
Label controls are typically used to provide descriptive text for a control. For example, you can use a Label to add descriptive text for a TextBox control to inform the user about the type of data expected in the control.
So while Labels and TextBoxes both inherit from System.Windows.Control they are different things, intended for different purposes. In the same way that oranges and apples are both fruit, but are different.
However, if you're creating an application and want to have something that looks like a label, but allows the user to select (but not edit) the text, then you can use a TextBox with the following properties set:
Backcolor = Control
ReadOnly = true
BorderStyle = none
As shown below...
Alternatively, if you have an application and want to get text from something like a label, you can use the Win32 API function GetWindowText, if you know the handle to the window that contains the text. In a Win32 context a "window" means just about anything distinct that is on the screen, not just the windows that you can drag around with your mouse. WinForms is an abstraction on top of all this.
As for getting the handle to the window that is under the mouse cursor, see this question.
Is it possible to create a WPF user control like this - a text region which is shown couple of lines initially and when user clicks a button it will open up the rest of the text ?
I have checked the expander class but dint find any properties with this behavior.
The nearest example I can think of of such a behavior is the ToggleButton.
You can modify its default Template to show whatever you want.
The default Template: http://msdn.microsoft.com/fr-fr/library/cc296245%28v=vs.95%29.aspx
I am using C# visual studio 2010 to develop an ASP.NET website.
I dynamically create a checkbox at run time.
CheckBox chkbox = new CheckBox();
chkbox.ID = "chk" + checkboxID;
// Add our checkbox to the panel
dynamicPanel.Controls.Add(chkbox);
chkbox.Text = checkboxName;
By default, the label is displayed to the right of the checkbox. I can successfully move the label from side to side by adjusting chkbox.TextAlign = TextAlign.Right / Left.
What I can not figure out for the life of me is how to set the Text above the check box.
I am not looking for any kind of hack like, verticle-align:-3px as this will not work for me because I let the user pick the font and size of the text. It will not always be -3px in depth.
I suppose you should go with a new Control where you add a separate Label below the Checkbox (actually wrapping the checkbox).
Derieve that class from CheckBox, and override (or define new if not virtual) the Text property, so it will now set the upper Label's text.
This will actually be a good example of Decorator pattern.
Set the text align property to TextAlign.Left then use CSS to set the label's display to: block.
Is it possible to add a "default" text value to a TextBox in WPF, with the text disappearing when the user clicks on the control or types anything in it ?
If it's not possible, how would I create a template which allows a user to define a text box with distinct properties for the content of the control and its initial value?
This is certainly possible. You can either:
1) Set the initial text normally, then on an event such as OnClick() or OnTextSelected() you can delete that text, then it will be blank before they start typing. You can also go one step further and add something to OnTextChanged() to see whether the text is blank and every time there is no content, your initial content can be set again.
2) Alternatively, you can create a custom style for your text block, with a text block inside of it, a property to set the text block text and an event hooked up to clear the text block text. This is nicer, but more work. I would recommend this if you wish to re-use this control.
I have a question? How can I wire up an button in a winform to take an input from a label, and put it in a text box to display the result?
I'm confused!
I have 4 labels... I want to be able to have people put input into the labels click the update button, and then display the results in the textbox below.
Any help? Thank you!
OK so basic outline of what you need to do:
1) Go to the toolbox and put textbox(es) on the form for the user to type in.
2) Add at least one label for your output text
3) Add a Button
4) Select each item on the form, go to its properties (f4) and set the Name property for each one to something that you can remember (this is how you'll reference the controls in your code)
5) Double click on the submit button. This will open up an "Event Handler" for Button.Click, which means the code you write will run when someone clicks the button.
6) Write the C# code to do what you want. For instance, this takes the contents of a textbox (tbInput.Text) and copies it to the label text (lblOutput.Text):
lblOutput.Text = tbInput.Text;
Hope this helps...if not, read the first 3 or 4 chapters of any beginning C# book.
You don't put input input into label, you do that in a TextBox. A label is a as its name implies a "label" (fixed unmodifiable text).
Most simply, create a method to handle the Click event of the button, bind it in.
Inside this method get the text from the labels, and then update the textbox with the input.
.NET standard Labels are not the controls you are looking for. Labels are just that...text labels that do not provide for text input. What you want is a TextBox, which you will be able to find in the Visual Studio Toolbox.
If you want the look and feel of a Label, but the functionality of a TextBox, you can modify the TextBox properties accordingly (border style, background color, etc).
Drop a Button onto your form, and from the Designer if you double-click the button, a _Click event handler will be generated in your source file from which you can implement the code to do whatever it is you want to do.