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.
Related
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 months ago.
Improve this question
Maybe this can't be answered without context but when I use Show():
TestView test = new TestView()
{
Owner = Application.Current.MainWindow
};
test.Show();
Everything works fine, the events are fired and my textbox/comboboxes are populated with data on the test view. But when I use ShowDialog() nothing is populated. Anyone know a reason why? I want a modal window.
This is by design.
As by documentation:
When a Window class is instantiated, it is not visible by default. ShowDialog shows the window, disables all other windows in the application, and returns only when the window is closed. This type of window is known as a modal window.
Modal windows are primarily used as dialog boxes. A dialog box is a special type of window that applications use to interact with users to complete tasks, such as opening files or printing documents. Dialog boxes commonly allow users to accept or cancel the task for which they were shown before the dialog box is closed.
Thus, the ShowDialog is blocking until the window is closed.
This means that dealing with events and similar, specifically from the Owner window will not work.
If you have additional questions, please show the relevant code with the events and how you populate them.
If for some reason you need a full blocking window - it is possible; but we will need more details.
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.
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
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
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
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.
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
Improve this question
In my project, I need to get the listview containing the data from the back end, If I place the listview in the form and upon clicking a button I can load data, but the requirement is initially the listview should be hidden or not present there, only on clicking the button the listview should be viewed with data. Thank you.
Set the List View's property Visible = Falsein the properity window.
Within the button click event handler set it to true;
listView1.Visible = true;
You use the Visible Property. At the form load, you set it to false and then in the button_click
private void button1_Click(object sender, EventArgs e)
{
listView1.Visible = true;
}
I think You should use listView1.Hide(); initially in Form constructor
And on button click You should use listView1.show()