I am developing windows application to ask user to enter password in pop up box on that i am not able to put password mask,
if any on know could you please help me out this i am new to visual studio
string pin=Microsoft.VisualBasic.Interaction.InputBox("Input User Pin Number", "Pin Number", "" );
There is no easy way of doing this with an InputBox. (You'd have to install a hook before showing the dialog, and then when it was displayed, hunt around for its textbox control and change its styles.) Better to just say "can't". The InputBox wasn't designed to be customizable. In fact, it wasn't even designed to be used by .NET applications. It's an old classic VB thing, provided in the compatibility namespace merely to facilitate porting classic VB apps to VB.NET.
There is no real advantage in using it. Just create your own form with a label, maybe an icon, and a textbox. Set the textbox control's UseSystemPasswordChar property to true. (You could do as rashfmnb suggested and set the PasswordChar property, but it is better to use the system's password character instead of your own, that way it always matches the user's expectations.)
Be sure to display your new form with the ShowDialog method so that it will be a modal dialog (blocking call), just like InputBox.
user PasswordChar Property of the textbox
You can't mask the chars in an InputBox.
If you look at Interaction.InputBox Method on MSDN, there is no way to set it to be password input.
You will need to create a new Form, add your own Label and a TextBox, then set the PasswordChar property in the TextBox
Related
I have a simple search field on a form that is set as multiline (which I understand is the only way to change a text box's height) and has the flag AcceptsReturn set to false.
However, when I press enter within that control, instead of it activating the default button as it should, it puts in a return character.
Now, I've also attempted using the KeyPress event to check if the Enter key has been pressed to activate the search-button click function in the hope that it would override this return behaviour - but it hasn't. Now it just runs the search AND inserts a return character.
I'm running Visual Studio 2010 (although this problem seemed to be present in 2008 too before I converted it) and C# .NET 2.0. Any solutions?
I see that an answer has already been posted, which mentions the AcceptButton property, but I figure I would state more clearly why that's necessary: quoth MSDN, on AcceptsReturn, "If there is no default button for the form, the ENTER key will always create a new line of text in the control, regardless of the value of this property." (I just tried it out on a dummy form - by "default button", they did in fact mean the form's AcceptButton property. With one set, the value of AcceptsReturn made a difference; without one, it had no effect.)
As for KeyPress, while that is obviously not the best way in this case, I have had to use tricks like that in the past - did you remember to set e.Handled to true in the case that you handled the event yourself?
The form has a property called AcceptButton. Is that pointing to the button you are calling the default button?
I just wrote a little test and it seems to work for me.
Just out of being bored, I decided to start building my own text editor. I have been having trouble with my coding, so my teacher had suggested building smaller programs that I wanted to write to help get me more familiar with the language, and since I couldn't think of anything, I ended up making this text editor.
I've been trying to root through the code on my own as much as possible, but I was wondering how to make the text that appears at the top of the form (beside the icon) reflect the current filename (or "new" or something if there is no file loaded) as well as having the * if the file has been edited.
I would also like to know how to code my exit button to check if the text has been edited before closing, and ask the user to save if it has, as well as having this show up if the user uses the "X" button in the corner, which currently flat out exits the program no matter what.
To change the title (text besides the icon):
Form1.Text = "This is a new title";
where Form1 is the name of you form object
To check if text is saved:
Hold a boolean variable that indicates whether the user saved the text or not.
Use the Form_Closing method to check if this variable is set to true, and do as you wish
More on Form_Closing here
Many questions :)
Let me answer a few of them:
In your own code, you should probably set a "dirty bit". In other words, declare a boolean variable that says whether or not the text changed. "Changed" is something you, the programmer, needs to define. It can mean many different things - you get to decide.
Each Winform "control" has a set of "properties", most of which you can change programmatically (on-the-fly). Your "form" has a "text" property that changes the title. Label, Button and other controls also have their own "text" property you can change at will.
Each Winform control also has a set of "events" you can override. The "Close" event is the easiest way to manage program shutdown - including if somebody pressed the "X" button. This is also a good place to check your "dirty bit", and save the file accordingly.
I have made a text editor control in C#, where I have inherited from Control.
Some of my users use an IME (Input Method Editor) for input, so I would like to add more support for it.
Normally, an IME will pop up where the caret is, but I can't figure out how to tell it where to show up. I assume there is some standard way of doing this, since there are some IME fields in the Control class.
I found a solution. The code here did it for me.
http://www.koders.com/csharp/fidEB8980C0605213D81D1D8364B00F09538F1DF83D.aspx
I am using Windows Form application. I want to open a small textbox on a window to enter user's name or Email in Starting for the program.
How can I achieve this?
Write one, 'tis almost trivial (creating the form and adding label, textbox and buttons) and using the VB one is perputating something that was only put in to appease the baying mob.
Key method is ShowDialog() which is a method on a Form.
On the form make sure you set the flags for the Ok and Cancel buttons correctly and provide a property (ideally) to allow you to read (and write if necessary) the text box
You can then do something along the lines of the following:
using(MyInputForm mif = new MyInputForm)
{
if (mif.ShowDialog() == DialogResult.OK)
{
dataFromDialog = mif.InputData;
}
else
{
// logic to deal with cancel
}
}
You can do something similar in WPF, don't have an example to hand though.
Maybe the answer to this question will help:
What is the C# version of VB.net’s InputDialog?
I've some questions .. and I really need your help.
I have an application.
First I display a splash screen, a form, and this splash would call another form.
Problem: When the splash form is displayed, if I then open another application on the top of the splash, and then minimize this newly opened application window, the splash screen becomes white. How do I avoid this? I want my splash to be displayed clearly and not affected by any application.
I'm using a DropDownList but I realized that there is 2 types of it . I found "Dropdown" which makes the text inside the DDL editable, and "DropDownList" which doesn't.
Problem: when I tried to use DropDownList control it doesn't allow me to add a default text while DropDown does so I want a DropDownList control which prevent modifying on the text and allow a default text .. what property should I use?
Can I add "?" which denotes to Help button to the FormBorder (with the minimization, maximization, and close buttons )
Can I change the colour of the Formborder from its default colour (blue) ?
One of my application functionality is to copy files from server to phone into a certain folder in memory card.
Problem : can I determine the free size of the MMC to notify the user if it's full while copying.
3) You have to set the "HelpButton" property of the form to true. However the "?" button is only visible if you deactivate the maximize and minimize buttons by setting "MinimizeBox" and "MaximizeBox" to false.
Here are a few...
1) you need to launch the window in another thread so that your app can do what it needs to do to start. When the startup finishes, signal to the splash screen that it can close itself.
2)
dropDownList.SelectedIndex = 0;
4) I would not recommend doing so. It is based on the system color scheme, which the user sets. I would not like an app to decide for itself which scheme to use.
5) if the MMC shows up as a mapped drive you could use one of these techniques
Once again there is no answer to this guys question.
Yes, do as the other guy said and launch the splash screen in its own thread.
There is only one type of ComboBox in .Net, However there is a property called DropDownStyle which sets its functionality.
Yes, I am clueless on how this one works and never needed it.
Yes you betcha, Its called non-client painting. you can find more info on it here http://www.codeplex.com/CustomerBorderForm/Wiki/View.aspx?title=Painting%20NonClient%20Area&referringTitle=Home
I Need more details on this.