Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am creating a windows form with the openFileDialog and the showFileDialog icons. But when I run the form, I do not see the options in the top left corner.
Is there some properties that I need to change to visible or something?
Any help will be appreciated.
These Dialog are not shown unless you perform any action (either clicking a save button or open file Button)
what you need to do create a button and then handle its click event
something like this.
this.button1.Click += new System.EventHandler(this.button1_Click);
and then in this event, you can invoke your dialog
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = openFileDialog1.FileName; // this is the selected file
}
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am quite new to this and I am building an easy app in visual studio in C# which is plotting graphs and user can customize them by using checkboxes and radiobuttons. These are linked to events and when checkstate is changed, the event is called and the code do its job. But these events are called even when the checkstate was not changed and all plotted areas reload multiple times which is not very pleasant to the user. Can you please advise me how to call the event only when it is required. It's WinForms. An example is below. I want to display the output in both cases - if the bool value is true or false, the output is dependent on this and the outcome is different.
`
private void CheckBoxCountInvalid_CheckStateChanged(object sender, EventArgs e)
{
if (checkBoxCountInvalid.Checked)
countInvalid = true;
else
countInvalid = false;
ShowOutput();
}
`
An (if else) sounds like if would work fine for that problem.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have an issue that I can't seem to resolve via Google (likely because I'm not searching the right criteria). I have a Closing Event that checks if a button is enabled and pops a messagebox with a result (Yes/No). If the user says NO, I get the desired results in the app; however, the X in the top right corner stops working. How to I "reinstate" the close button ("X" in the top right hand corner) so it works again if pressed (and also evaluates the logic again).
I tried this: Stackoverflow Question
i don't think I want to play with Visibility of the window. The window doesnt go anywhere. They have dirty data and they need to fix it or have it auto saved.
What I have in the application is:
private void DXWindow_Closing(object sender, CancelEventArgs e)
{
if (BtnPatSave.IsEnabled == false) return;
if (MessageBox.Show(Properties.Resources.PatAcctMsgBox3, Properties.Resources.PatAcctMsgBox1,
MessageBoxButton.YesNo,
MessageBoxImage.Warning) == MessageBoxResult.No)
{
e.Cancel = true;
}
else
{
var patId = TbPatId.Text;
var usl = new UnSetLockValue();
usl.UnSetVal(patId);
Log.Info("Patient Account is now unlocked by user: " + Environment.UserName);
}
}
Thats because you are using the MessageBox class.
It disables the "X" button to allow the user only to provide the values you specify.
If you don't want this behaviour i think you have to create your own "MessageBox".
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I want to make an event that when entering text into the text box the first letter of the text to be capitalized automatically in fastest way.
Try something simple like this:
create a text_changed event on the text box
private void textBox1_TextChanged(object sender, EventArgs e)
{
{
if ((textBox1.Text.Length) == 1)
{
textBox1.Text = textBox1.Text[0].ToString().ToUpper();
textBox1.Select(2, 1);
}
}
}
Should you have issues with the formatting of the text due to other requirements, than it needs to be done in a different way.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
So I have a project with two forms: the MainForm and AnotherForm.
In the MainForm I have a button which should open the AnotherForm. I'm using the following code to do that:
private void btnTimeReminder_Click(object sender, EventArgs e) {
AnotherForm anotherForm = new AnotherForm();
anotherForm.Show();
this.Hide();
}
The problem is, when I click the button to open the "AnotherForm", it just opens a blank form in the WindowsDefaultPosition. All the design of the AnotherForm is deleted (The buttons, images, even the size of the AnotherForm).
I have no ideia why is this happening... Am I using a bad code to open the form?
Ensure that
InitializeComponent();
is being called in the constructor of your new form.
If you need to change the initial position of your new form, you can use
anotherForm.StartPosition = FormStartPosition.CenterParent;
or whichever start position is necessary.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a MenuStrip in my Windows Form Application which Contains MenuItems.Now As per my requirement i have to check some condition and enable/disable the visibility of MenuItems in the MenuStrip bar but i dont know how to do it.
Suppose Normal User is accessing the application ,then Some MenuItems will be hidden and if Admin user is accessing the application then all MenuItems should be visible.
Please help me .Thanks in advance.
You can Set the Visible to false:
if (UserIsAdmin) // User is admin so he can see the menu item
menu.Visible = true;
else // user is not admin, so he can not see the menu item
menu.Visible = false;
UserIsAdmin is a bool variable which is returned by your code to indicate user level