C# no PasswordChar field missing from textbox - c#

Im writing a c# program using vs2015, however there is no option in the properties field of the textbox for PasswordChar. Im trying to make it so the textbox would show '*' instead of the inputted text.
I have tried manually coding in mytxtbox.PasswordChar = '*' however I get the error "TextBox does not contain a definition for PasswordChar"
Thanks in adavance.

You should be using PasswordBox instead of TextBox.
Note that you will need to use an attached behavior to enable binding of the value to a ViewModel property as described in this tutorial.

Related

How to set mode Password for TextBox control wpf without passwordbox?

I need to USE hidden inserted symbols in my textbox and show "password" like "*******".
But after this I will use inserted password for login. I can not use PasswordBox because it don't have need touch event.
How do I do it ?
You should check out this answer to a similar question:
https://stackoverflow.com/a/481097/4192732
You basically need a third-party extension to avoid using the passwordbox, as there are no first-party methods of masking a WPF textbox.

Silverlight C# - Set selection in textbox via code?

I'm working on a spellcheck function for my app, and want to have the word that's currently being looked at highlighted. I'm tracking the char count as I loop through the words in the textbox, so I know where to set the selection at.
I've tried txtArticle.Select(0, 10); just as a test, as well as setting the txtArticle.SelectionStart and txtArticle.SelectionLength properties, but the textbox doesn't show anything highlighted. What's the dealio?
Actual code I've tried:
txtArticle.SelectionStart = charCount;
txtArticle.SelectionLength = checkedWord.Length;
as well as
txtArticle.Select(charCount, checkedWord.Length);
I've positively no idea what I'm doing wrong, unless you can't set what's selected in the TextBox via code, which I just can't imagine is the case. Is there perhaps some extra property that I need to set for the TextBox itself?
Thanks yet again!
-Sootah
Documentation on MSDN of TextBox.SelectionStart Property has an example that works. This states that programmatic text selection is actually supported in Silverlight.
Looks like something else is going wrong in your application. When do you call this code? Try calling it after everything is loaded, and rendered on screen. May be on a click of a button.
If above does not work, create a sample application/page and try to follow MSDN example. When you get it working, try to figure out why it doesn't work in your application.

C# How to set default value of a string collection in Design

In WinForm, I have a combobox with DropDownStyle set to DropDownList (so can't enter a Text). In the properties window, there is the Items property which is a string collection. I enter all my values.
But now, I would like to set one of these value by default (instead to have the empty entry at run-time). I know how to do this via coding, but I am pretty sure (damn memory) that it was possible to set one of the value in the string collection as default by adding a special symbole in front of the line.
Anybody know that symbole? Or my memory is playing me trick and it is not possible to do it via the designer?
Doesn't look like it can be done when using a DropDownList. From here it is suggested that you can set the text property to the default value you want, but this will only works in a DropDown rather than DropDownList style.
I'm sorry but that is not possible within the Designer only, since the Text property is used for this feature and that property is ignored/cleared when the using a DropDownList.
If you don't mind having your data values outside of the Designer, you could probably use DataBinding to accomplish this since the DisplayMember and ValueMember properties of ComboBox can be used in the Designer and would set the display value. I don't normally use DataBinding so unfortunately I cannot provide code examples - perhaps another user can chime in?

How to show a text as hidden using c#

I am developping in C#.
I need to capture a password written inside a Text Box, but would like to not show the password that is being typed, showing instead **** or any other character to hide the password.
How can I do that? I'm sure it's by modifying an attribute, but can't find which one.
http://msdn.microsoft.com/en-us/library/d3223ht2.aspx
set the PasswordChar property of the textbox
Set the PasswordChar property.
There is a property on the TextBox class called "UseSystemPasswordChar" (assuming winforms) that let you do this.
To use your own custom character:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.passwordchar.aspx
To use the system default character:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.usesystempasswordchar.aspx
textBox1.UseSystemPasswordChar = true;
//or
textBox1.PasswordChar = '%';

Infragistics WebTextEdit - Setting value in Javascript function

I'm currently using the Infragistics component set for .Net 2.0, Visual Studio 2005 and C#. I have the following chunk of javascript code (text and other variables are declared elsewhere):
***alert(box[select].value);
text.value(box[select].value);
alert(text.value);***
'text' is an Infragistics webTextEdit, while box is just a standard listbox. The two alerts seem to be working fine. Before I set the value, the listBox's selected value might be 'hello', and the alert box which pops up after I've assigned this value to 'text' is also 'hello'.
However, the value shown in the box on my form never appears to get updated. Anybody have some suggestions as to where I'm going wrong, gotchas in how Infragistics handles this kind of thing or anything else? I'm aware there may not be enough info here to diagnose the problem.
The value property is only available server-side. Using it client-side won't do anything. Setting it would have to be done server-side, or you'll need to craft fun javascript to address the text of the element that the control is actually rendered as in the browser.
http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Infragistics2.WebUI.WebDataInput.v7.3~Infragistics.WebUI.WebDataInput.WebTextEdit~Value.html
Unless I misunderstand the question, if text is an instance of the Infragistics WebTextEdit, you should just be able to do:
text.setValue(box[select].value)
Or if text is the underlying input control, but 'id' is the ID of it,
var edit = igedit_getById(id)
edit.setValue(box[select].value)
See the WebTextEdit CSOM for more.

Categories