Short question here:
In .Net 4.0 Winforms, how do I use the PasswordChar property of a Textbox to show a common black dot as a character? Is there perhaps some font I can use that has this as a character?
If I use 'UseSystemPasswordChar = true' it shows an asterisk (*).
You can use this one: ●
You can type it by holding Alt and typing 25CF.
Alternately, you may use this smaller one: •
You can type it by holding Alt and typing 2022.
Use the Unicode Character 'BLACK CIRCLE' (U+25CF)
http://www.fileformat.info/info/unicode/char/25CF/index.htm
To copy and paste: ●
I was also wondering how to store it cleanly in a variable.
As using
char c = '•';
is not very good practice (I guess). I found out the following way of storing it in a variable
char c = (char)0x2022;// or 0x25cf depending on the one you choose
or even cleaner
char c = '\u2022';// or "\u25cf"
https://msdn.microsoft.com/en-us/library/aa664669%28v=vs.71%29.aspx
same for strings
string s = "\u2022";
https://msdn.microsoft.com/en-us/library/362314fe.aspx
One more solution to use this Unicode black circle >>
Start >> All Programs >> Accessories >> System Tools >> Character Map
Then select Arial font and choose the Black circle copy it and paste it into PasswordChar property of the textbox.
That's it....
Below are some different ways to achieve this. Pick the one suits you
In fonts like 'Tahoma' and 'Times new Roman' this common password character '●' which is called 'Black circle' has a unicode value 0x25CF. Set the PasswordChar property with either the value 0x25CF or copy paste the actual character itself.
If you want to display the Black Circle by default then enable visual styles which should replace the default password character from '*' to '●' by default irrespective of the font.
Another alternative is to use 'Wingdings 2' font on the TextBox and set the password character to 0x97. This should work even if the application is not unicoded. Refer to charMap.exe to get better idea on different fonts and characters supported.
Instead of copy/paste a unicode character or setting it in the code-behind you could also change the properties of the TextBox. Simply set "UseSystemPasswordChar" to True and everytghing will be done for you by the Framework. Or in code-behind:
this.txtPassword.UseSystemPasswordChar = true;
Related
I have a RadMaskedTextBox in usercontrol and i change it's mask in page load to accept date or money or integer or string.
(For example :
txt.Mask= "###,###,###,###";//for money
txt.Mask= "####/##/##";//for date
)
For each item i could change the mask except string,I don't know how to set mask for string(to accept all words and numbers)?
To accept any character at a given position in your mask, you'd use the placeholder a.
This is right in Telerik's documentation on mask behavior:
Mask element a: Accepts any character. If this position is blank in the mask, it is
rendered as a prompt character.
On the other hand, if what you're looking for is to completely disable the mask feature in certain circumstances, you'll have to add an alternate control, such as RadTextBox, and enable it instead. This is mentioned in a thread in the Telerik forums. For Silverlight and WPF, the RadMaskedTextBox control has a property "MaskType" that can be set to None to disable the mask, but the ASP.Net version of the control doesn't have this.
I don't really know what kind of this task to call. For some characters/string, if you display them in a TextBox with some font (I call it Font 1), it displays them correctly. But if you change the font of TextBox to another one (I call it Font 2), the character/strings may be displayed wrong (wrong font). What I want is how to convert those characters/string (as displayed in Font 2) to some corresponding characters/string/values (as displayed in Font 1). I have to do this because in my language, there are not any character like the ones displayed in Font 2.
To make it clearer, for example:
I've encountered a case in which the correct character was 'ă', however there was another 'expression' like '¨' which will be displayed exactly as 'ă' in Font 1, however in Font 2, it's displayed as '¨'. '¨' is not a character/letter in my language alphabet. It looks like that this is related to Font issue. This is like a problem with Input and Output:
Input: The weird/wrong character (like as '¨') and the Font in which that weird/wrong character displays correctly (like as 'ă'). That Font is Font 1 as I called above.
Output: The correct character (like 'ă'). I'm sure this character should be displayed correctly in almost Unicode Font. So the specified Font to display the output correctly is not necessary to mentioned here, and if it is a condition for the output (choose some specified Fonts for displaying the output correctly), I think it'll be OK because I intend to display the output characters in some fixed Font.
One of the 'converter' (calling it converter is not exact, maybe a translator) I have already is any TextBox. This should be called translator because it can help you translate the weird/wrong character to the correct one (you can see the output), however it's not a converter because you can't grasp the output, for example, select and copy it to Clipboard and paste to another textbox (such as Google search box). The TextBox operates like a translator, it receives the input (the weird/wrong character is assigned for the Text property and the Font is assigned for the Font property) and gives out the output (the correct character but as I said, you can only see it, not grasp/get it or at least get the corresponding character which is displayed correctly in another Font).
If this can't be done, I'm afraid that I have to add a column called 'FontName' or 'FontFamily' to my table so that every time I query the text from my table, I have also to query the corresponding Fonts to display the texts correctly on my forms/grids. This is one of the most annoying things I've ever known.
I hope you understand my problem. As I said, I even don't know what kind of task it is, but you may know. Please help me out.
Thanks!
UPDATE
I want to give an example of the converter, see it as a function/method like this:
public char GetCorrectChar(char c){
switch(c){
case '¨':
return 'ă';
case 'Ç'
return 'ầ';
....
}
}
This function is possible to implement, however it requires me to collect all the possible pairs (of the input chars and output chars) and I'm not sure if it's efficient. Thanks!
This question already has answers here:
Enter "&" symbol into a text Label in Windows Forms?
(5 answers)
Closed 9 years ago.
I want to display the text a&b in my LinkLabel.Text.
linkLabel1.Text = "a&b";
This displays:
ab
If I change the code to:
linkLabel1.Text = "a&&b";
one & sign will show.
a&b
Is this the correct way to print one ampersand?
& in winform is used for short cut key with Alt. By using double && you are escaping the shortcut key modifier.
So for "a&b" , shortcut/hot key would be: alt+b
You may see: How to: Create Access Keys for Windows Forms Controls
Set the Text property to a string that includes an ampersand (&)
before the letter that will be the shortcut.
& is a shortcut key from winforms controls.
"a&b" means; shortcut key for alt+b
Check out: Create Access Keys for Windows Forms Controls
To include an ampersand in a caption without creating an access key,
include two ampersands (&&). A single ampersand is displayed in the
caption and no characters are underlined.
// Set the letter "P" as an access key.
button1.Text = "&Print";
Also I found Label.UseMnemonic property.
Gets or sets a value indicating whether the control interprets an
ampersand character (&) in the control's Text property to be an access
key prefix character.
Use UseMnemonic property.
You can get it over here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.label.usemnemonic.aspx
& is a special char in control text properties. It's used for instance to underline context menu hotkeys. For instance &File will get you the word File with the F underlined
To extend on Freelancer's answer - yes, set the UseMnemonic property of your label to true, and this will show a&b as a&b, rather than ab̲
However, this will stop you from assigning an Alt+ shortcut, as described in other answers.
I am looking to handle incoming telnet text that has ANSI escape codes. For the bounty I am looking for a full implementation where I can just append text to the end of a buffer. The control should be scrollable, yet still be able to handle appending text, cursor positioning, etc.. while the user is scrolled out of view.
For example,
"\e[0;32mHello \e[0;37mWorld"
Would display a green "Hello" and a white "World"
As this would need to handle cursor positioning, setting a default 80 characters per row (80 columns) would be fine, but also needs to handle other column sizes. Would be nice to be able to change the font as well.
See Wikipedia ANSI Escape Codes for more information.
Take a look at Dart's Vt.NET control (assuming that a VTxxx emulation is close enough to an ansi emulation).
checkout the following link:
AckTerm # sourceforge.com
i'm trying to translate ANSI codes coming from a serial interface using Terminal Control project from www.sourceforge.com written in C# - if ackterm won't be good for you google terminal control project
hope it is what you are looking for...
Assuming you mean "ANSI escape code," you can start by converting each escape code in your string into a color (since it sounds like those are the only codes you're interested in). Just use a table like the one here (bottom of page) and do a little bit of custom string parsing.
ANSI escape codes are pretty old-school, so I wouldn't expect them to have the intended effect. They're meant for controlling output to text terminals, not fancy stuff like a .NET user control.
Are there any VS.NET plugins that will format a selection of code for printing or emailing and is also free?
Have you checked the inbuilt formatting provided by VS? Select code and enter key chord Ctrl+K, Ctrl+F.
Or goto (menu)Edit->Advanced->FormatSelection or Edit->Advanced->FormatDocument
If you copy your code from Visual Studio and paste it into Word, the syntax highlighting will be kept.
Alternatively, you could take a look at the Copy Source As HTML add-in.
Is this just a matter of using spaces instead of tabs to do indent your code?
try Artistic Style 1.22, http://astyle.sourceforge.net/
it's easy to use, has 3 or 4 predefined styles and is configurable.
Use some kind of tabs-to-spaces function, and make sure the print or email uses a monospaced (aka. typewriter or console) font.
I'm pretty sure VisualStudio had a (little well hidden) function to convert indenting from tabs to spaces and vice versa.
I'm normally using vim where you can use:
:set expandtab
:%retab
to replace tabs with spaces and:
:set noexpandtab
:%retab
to replace spaces to tabs.
Spaces is better for emailing etc. because noone can agree on the length (in spaces) of a tab.
To turn tabs to spaces, select the code and use Editor -> Advanced -> Untabify Selected Lines.