c# Buttons as toggles [closed] - c#

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
Hello i am new in C# and need some help
In both groupboxes have buttons they are now like toggle butons, but now can i choose only one button from all.
looking for:
clik one from Groupbox1, one from Groupbox2
clicked buttons will have green background
after press OK show messagebox with button name GB2 + " - " GB1
....................................................
Another question:
Buttons 1-6 can be added as dynamic buttons directly from SQL?
From Sql need have ID and Name
....................................................

Just some hints:
Use a RadioButton with Appearance set to Button.
Check the Remarks of the radio button to find out how to make two groups.
Subscribe to CheckedChanged event and set BackColor according to value in Checked property.
To dynamically insert buttons, take a look into designer.cs file. You can create your own buttons exactly the same way at runtime by doing the same stuff in your own method which you call whenever needed with desired parameters.
For the message box message check the state of all radio buttons and take the name from the box where Checked is true. (Advanced users would filter the Controls property for the desired type and value by using LINQ).
If you have started all of these and have a more concrete question: Ask a new question for one problem. Don't hope to ask one question containing all your questions and get a working example back.

Related

Circular Progress Button WPF/C# Custom Control [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to make a button in my WPF windows application that is primarily a circular button. I have found plenty of tutorials online using numerous different methods such as templates and styling so that part I can figure out.
The catch is that I want the custom control (which is what I think I want because from my understanding just styles alone wont let me modify core functions of the button and user controls are more groups of already done controls) because I want something that is part button and part progress bar. I want it to be a circular button with a gray strip around the perimeter of the button a few pixels thick that when I press and hold the button I can start a circular blue strip around that gray perimeter and when the blue reaches the top after one revolution some event may be triggered in the code.
I have been trying to find stuff online but it seems like there is a lot of disjointed and confusing tutorials on how to make custom WPF controls. Some are for expression blend which doesn't totally match the blend that installs with visual studio community 2015 so I am just thoroughly confused and was hoping someone could point me in the right direction. Thanks in advance!
You can easy customize regular button or toggle button:
Open project in VS
Right click on xaml in solution explorer you want to edit
Click on "Design in Blend"
Select Assets tab
Find "Button" in controls and drag it to page
Right click on the button on page
Edit template -> Edit a copy -> OK
Objects and timeline tab -> right click on border -> Change layout type -> Canvas
Remove backgroun from the canvas in properties tab
Drag elipsis from Assets->Shapes
Adjust elipsis size
Goto States tab -> Selected "Pressed"
Change color of the ellipsis in pressed state
... to be continue.
You don't necessarily need a custom control. You can have a UserControl with a circular button, and overlay a circular Path over the edge of the button. Set that Path object's visibility to false initially, and when you detect a left click down event on your button, make that circular path visible and start a rotate transform animation on it. You should be able to expand on this to stop the animation when you want to; your description doesn't fully describe what ways you want it to stop.
Hope this helps!

How can i have a pages text change based on the button clicked on the previous page in c#? [closed]

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 Pricing Table with 3 options, all on Upgrade.aspx.
'Starter'
'Champ'
'Master'
There is a button for each option. They will all navigate to Payment.aspx, but i want some variables, such as cost, and plan name, to be different based on what button they clicked on the previous page.
So if they clicked 'Starter' button, the Payment.aspx page would say Starter. But if they clicked the 'Champ' button, the Payment.aspx page would say Champ.
There are a lot of different ways you could do this. It seems a little ambiguous what would work best for your situation however.
One option is to create a singleton class with a variable which you set via button handles (IE sets the variable to "Starter" if that button was pressed).
Then the view for the Payment.aspx page could pull the information from the singleton class or consume it however you want it to.
You could also use form data, cookies, databases, and a variety of other things. It depends on where you want to store the data and how is easiest for you to store it.
There are a ton of facilities for this kind of event handling. I'd recommend looking at this article and see how it works for you MSDN - Cross-Page Posting in ASP.NET Web forms

C# - Drag and Drop files in win form [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make like a container application where you can drag and drop files of any kind on the form and afterwards to be able to open it from there. I found some solutions where you can drag and drop files to a list view and you get it's path.. but is not how I want.. I want to have on my form in a panel or what ever is better like a shortcut of the file, an image or something to be able to see the file icon like is in explorer.
Have someone ever done something like this or point me to the right direction?
Set "Allow drop" property to "true" on your control and make use of Control.DragDrop event - it's exist on all controls, and it's invoked after drag'n'drop anything on anything(if "Allow drop" is true of course).
It this event-handler you can add new item to this or another control(ListView fits nicely to your needs), and for example to some "Dictionary" where you will store "Item and filename mapping".
Also you need to make handler for item click'ing - for ListView there a ItemActivate event. Inside this handler you can click execute default shell-action for this file by using Process.Start

How do GroupBox's and RadioButton's work together? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Could anyone explain me how the compiler knows to perform appropriate method when we select RadioButtons in this example ?
It's hard to say for sure what you're asking. I think you're asking how the system knows that it should execute the iconType_CheckChanged method when one of the icon radio buttons is clicked, and how it knows that, for example, the asteriskRadioButton changed.
The answer is in two parts. First, in creating the program in Windows Forms, you hooked up the CheckChanged event handler for each of the radio buttons. So the asteriskRadioButton CheckChanged method contains the value iconType_CheckChanged. That information is added to the partial class that you don't usually see. It's in your Form.Designer.cs file in the InitializeComponent method. It looks something like:
this.asteriskRadioButton.CheckChanged += iconType_CheckChanged
You don't typically see the Form.Designer.cs file. To view it, expand the form node in the Visual Studio Solution Explorer and you'll see the file listed:
The second part of the answer is that when you click the radio button (or when some code changes the state of the radio button), the underlying control machinery calls iconType_CheckChanged, passing a reference to the control that triggered the event in the Sender argument.

Excel VSTO ->Hide/Unhide Ribbon Button based on another Ribbon Button click [closed]

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 2 years ago.
Improve this question
We are creating Excel 2007 AddIn using VSTO. Now we have a scenario where in there are 2 buttons. Button 'A' and Button 'B'. Button 'B' needs to be hidden based on the click on the button 'A'.
But since the ribbon bar is not getting refreshed dynamically we are unable to see the change on the Ribbon Bar.
I heard from some blods we need to use callback methods for the same. If that is so, how can I do that?
Two remarks:
1) in order to "force" a refresh on the ribbon you can call ribbon.Invalidate();
This may be useful if you need to programmatically enable/disable buttons or other items.
2) dynamically hiding/showing buttons in the ribbon is against the Ribbon UI Guidelines, which you must comply. I'm not sure if it applies to Office Add-ins as well (or only to standalone applications), but I would be surprised if that's not the case.
You can read more here: http://msdn.microsoft.com/en-us/office/aa973809.aspx
Here is how I solved it:
Step 1: Make Button "B" visible False
Step 2: on Click event on Button "A" make it visible true.
I got confused by reading too much, and made simple question a complex one.

Categories