In a recent project I'm planning to allow the user to make certain configuration using a MessageBox with various CheckBoxes. The number of these CheckBoxes is variable and depending on the amount of entries the User made beforehand, so I don't know how big of a Box I need and how many CheckBoxes there will be inside it.
When the user is done checking and unchecking, he will press the "OK" Button and the values should be returned and saved.
Multiple questions to this whole thing:
1. Is this a good/logical way to approach this whole thing? (Having the user make yes/no configurations to an unknown amount of options)
2. How would I create a MessageBox/Pop-Up with an uncertain amount of CheckBoxes?
3. Is there any smart way to design that box, so that it is not to big or to small and fits every option evenly spaced?
Is this a good/logical way to approach this whole thing? (Having the user make yes/no configurations to an unknown amount of options)
Yes, what else could u do if the options to agree with depend on previous settings. So yes this design is ok.
How would I create a MessageBox/Pop-Up with an uncertain amount of CheckBoxes?
In general, i highly suggest to not use the standard MessageBox of the .NET Framework. I would make my own window, and place all in with an yes/no button.
Is there any smart way to design that box, so that it is not to big or to small and fits every option evenly spaced?
Design ur window based on a Grid. Then pick a place that can be ur viewing area. In this place add some kind of stack control ae StackPanel. Then just load dynamically ur controls into this stack and ur done.
Related
Intro:
I am quite new to C#.
It is my job to create a certain simulation program.
I can't ask other programers, I'm an intern with a nonprogramer adviser and should not nother them. (I'm doing more of a fun project.)
So before spending a week or two to get really into WPF, I wanted to make sure it fits my needs.
If not, I want to use something else.
What I need:
Show the user a range of radio buttons to decide wether a simulation/plot/opening_of_svg should be done or not. (Can be done.)
A button "Add Task" where the user can choose one. (Can be done.)
Depending on the choice, add a certain form into the existing one, where parameters can be set. (Not found.)
Some of them radio buttons. (Can be done.)
Some of them text box, for integers and doubles only. (Can be done.)
All of them with default values. (Can be done.)
After adding a task, another "Add Task" button should be created, for adding more of them. (Not found.)
If for example a second simulation is added, it should take the values of the first one as default. (Can be done.)
Save the choices and data to a text file in a certain syntax like "Gnuplot Add Restriction = Time" which is used by the rest of the program. (Can probably be done.)
Question:
The biggest uncertainty is the one with adding forms into the forms.
Can this be done in WPF?
If there is any other framework (if this is the right name) specially made for this, feel free to comment.
I can't add many links due to my reputation. I might do it later. Just in case someone will find this later and wants to know about how.
Rather than creating Forms, consider creating UserControls and arranging them within a single Window. This is the same pattern you might use when creating composite windows in WinForms. I'd recommend the Grid or DockPanel layout panels.
In this respect, WPF is quite similar.
In addition, it sounds to me like you are doing a feasibility study for a new requirement. Are you sure it is not appropriate to speak to more senior staff? If I was them, I'd want to know your findings!
On reflection...
It seems like you are trying to create a branching Wizard workflow, like an installer might give you, i.e. Next, Next, I Agree, Next, Finish. WPF Can absolutely do this and some open source solutions already exist. For example, Avalon Wizard.
I have a program I created which amongst other things has 20+ buttons which link to various sites and programs I use for work. The program has started being used by other people and the buttons don't quite meet their need.
What I would like to do is allow the user to set the button up to direct to a specified URL at runtime, and maintain that information for future use (I'll work on that bit later) - Allowing every user to cater it to their own criteria.
To make this easier, the buttons already exist with a generic name, and no text, and are initially invisible. All of them when in use would direct to a particular URL, nothing else. I would like the user to be able to click an "Add" button, set the button Text, text colour (I can do this bit) and fill in a text box to set the url for the browser (Default browser, not webBrowser.), which they would save, making the button visible, and usable.
I've had a look around, but cannot for the life of me work out how to do this.
Some guidance on the issue would be fantastic
Thanks in advance
Anthony
You could accomplish this using a DataGridView with a DataGridViewButtonColumn.
Because I had a set number of available buttons, I was able to create them and hide them. Set it up so the user sets the variable that the Start.Process. is using for the url, as well as set the button text in real time.
They save this information in a text document that's stored in the programs home folder, and this is pulled back through when the program is re-opened. This will work well for my simple purposes.
Question:
Is there some effective way to hide some portions of the WinForm/WPF desktop program based on user settings/permissions?
Why I need this?
I'm starting a big accounting project which will contain hundreds of forms/dialogs.
The program is going to launch a main window which shows 1 to 4 divisions. The user selects each of those and it will then launch the a window which contains a sidebar with a bunch of buttons on sidebar (something like Microsoft Outlook). Now, when the user clicks on each of these buttons, it will open that section of the program and the user will work with that part. Based on the user permissions/settings, there's a need to sometimes hide some of these buttons though. For instance suppose I have 4 main divisions A, B, C and D. When you launch A, you'll get a sidebar containing A1, A2, ..., A100. A user might opt to see only A1 & A50!
Our initial approach was to use WinForms for this because the team was very familiar with it. I suspect that for doing so, we have to build some sort of model which contains information about user preferences and write lines of code like btnA1.Visible = false; a lot.
Frankly just thinking about doing that disgusts me. That's why I'm looking for a better way to achieve such result. I've searched around and found PRISM.
I'm not sure just yet but I think to use PRISM I need to make each of those buttons or their dialog a module and load them after I decide which of them is needed for the user.
It seems like a nice way to do this but considering the fact that this project is very urgent and we don't need to load different modules for different users (we just need to load them - ideally on demand - and sometimes hide some), I have some concerns:
My team might need some time to learn WPF
All of us don't know much about Unity and PRISM.
This might be overly complex, i.e. there might be a more simple way to achieve this without going into such lengths.
Also, I'm watching Prism & Silverlight Series and PRISM5 for WPF from Channel9.
a window which contains a sidebar with a bunch of buttons on sidebar (something like Microsoft Outlook). Now, when the user clicks on each of these buttons, it will open that section of the program and the user will work with that part.
That sounds to me like a TabControl. You'd rather not try to reinvent the wheel as it's already been invented.
The only difference between that example and your requirement is that instead of hard coding the tabs you're going to bind to a collection of ViewModels, like this, and then have each instance of TabViewModel toggle it's own IsVisible property depending on user permissions / user selections.
Simple as that. No need for complex MVVM frameworks. No need for silly obsolete useless winforms stuff.
I'm using a Wizard in my ASP.NET page, where in the first step the user chooses from a DropDownList, how many sets of controls will appear in the next wizard step (from 1-5).
For example, in the 2nd step of the wizard there are 3 textboxes. If they choose 2 on the previous screen, there will be 6 as there will be 2 sets of these.
I need to be able to store the contents of all these textboxes in a database (simple part I think, there's 5 columns and all can be null.
The easy way of doing this I think is just creating all of the possible controls (5 sets), and hiding them based on what they choose in the previous screen. Is there a more efficient/easier way?
Thanks
It really depends on your definition of efficient/easier.
A more standard approach would be to use a repeater control to display the correct number of controls based on previous input. However if you have not used a repeater control before there will be a degree of learning involved in displaying your output and retrieving user input during the postback.
You can use the ASP.NET Wizard Control
If you absolutely know that 5 boxes is the max, and it is highly unlikely that there would ever be more than that, using Control.Visible on the server controls and their interface items such as label or what ever else, would work... but...
It's a bit brittle of a solution, though; Requiring you to make manual code changes in a few places if you decide to add more possible boxes.
A dynamic solution would let you set a maximum number of options in config, or just a single place in code. It would probably require you to change your database structure a little bit, but that would likely be better for normalization, anyway. It involves dynamically generating the items in the step of the wizard, too.
(More info on that option can be had if desired!)
In my projects (WPF) I use System.Windows.MessageBox to show the user a confirmation dialog for operations that are critical, such as a delete-operation.
My problem is that if I specify as button value MessageBoxButton.YesNo, the user cannot use the escape-key to cancel the operation. IMO this is one of the most annoying things, a program can do, showing a dialog without the possibility to cancel/close the dialog through the escape-key.
Other possibilities are MessageBoxButton.YesNoCancel, but IMO this is confusing because it shows three buttons for only two operations . Or one can use MessageBox.OKCancel, but this is IMO not clear enough. In my dialogs I want to ask the user if her really wants to execute the operation. And for this, a simple ok is not appropriate. A yes (I want) is much better than an ok (go on).
How do you handle this? Is it a non-topic or do you think as I do and have an own MessageBox-implementation or do you know a possibility to extend the System.Windows.MessageBox-class?
Make a custom message box (inheriting from Window) that has placeholders for header/message and confirmation button text. Then you can design a nice, attention-grabbing dialog that will stand out from the hundreds of standard OK/Cancel MessageBoxes a user typically sees. For example, you can use a larger header font similar to the Windows Vista dialogs, or include a custom image.
Then, you could obviously handle the Escape key yourself, and define the default Escape behavior on a per-dialog basis.