Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last month.
Improve this question
I have a WPF application which uses TabControl. When I select a tab that shows a list of items and then select an item it will open a new page under the same tab. What I would like to achieve is that I can click the selected tab button and get back to the item list (like some sort of back button). I tried different tabcontrol options and neither of them detected another click. One way would be to apply an overlay over tab button which would allow another click to reset the tab page. I searched on StackOverflow but haven't found a topic that would cover that issue. Is there a better way to achieve this?
Thanks,
Jan
You could handle the MouseLeftButtonDown event for the TabControl to detect whether a selected tab was clicked:
private void TabControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.Source is TabItem tabItem && tabControl.SelectedItem == tabItem)
{
MessageBox.Show("You clicked a selected TabItem!");
}
}
Sample XAML:
<TabControl x:Name="tabControl" PreviewMouseLeftButtonDown="TabControl_MouseLeftButtonDown">
<TabItem Header="1">
</TabItem>
<TabItem Header="2">
</TabItem>
</TabControl>
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 4 years ago.
Improve this question
Currently,I am using MahApps.Metro Combo Box and Can i split event of Combo box click event and toggle button click? Like this=>
Please Check Image Here
My requirement is when i click Click 1,I don't want to show drop down list and just do click event.
But when i click Click 2,I just want to show drop down list and not trigger click event.
How can i achieve this? Thanks.
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
How can I add a border with title to a panel using c# like this:
see this pic.
Open the toolbox
Select the GroupBox control and drag it onto your form
Set the groupbox Text property to the desired caption
Drag other controls inside the groupbox
What you looking for is called GroupBox
For more information about GroupBox refer to this link.
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 8 years ago.
Improve this question
I want to see a TextBox value only for a TextBox when moving through the sql table items
But when I click on the Add new button the TextBox must be editable for the new item
Just change the TextBox property ReadOnly to false in the click button.
I think that if you add a event to add on the bindingnavigator you can change ReadOnly property of the textbox
In the button OnClick action change the TextBox property ReadOnly into false. And return it back to true when another condition is satisfied (of your choice).
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 am beginner in visual studio and I heaven't found the answer on this yet.
Well, I have two drop down lists. Each of them has 7 values. I want compare each value from first drop down with each value from second drop down and the reasult must show in a special label.
For example, if I choose "2" from first drop down and "3" from second drop down list, in a special label must appear "5" as an reasult. How can I do that?
Also, I'd like to add a button which will compare two listed values.
Sadly im not sure if i've understood your question right
For that: if in one combobox is one value in second another it would be something like that u have to add new event to both.
and it will look something like that:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int result = 0;
result = Convert.ToInt32(comboBox1.SelectedItem) + Convert.ToInt32(comboBox2.SelectedItem);
label1.Text = Convert.ToString(result);
}
For each of them, you can add also some ifs to check values and as well catching exceptions.
If u would like to ADD values after button click - u should simply ignore above code and add button and then add event for onClick (simply double click button on your form)
with similar code inside.
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
I am Creating an app with C#. I have a ListView on the Main Form(FormM) which lists all the record, i can select on record and edit it in the new form(FormC). Now I want to have a Navigator on the Main Form. Suppose that the FormC is open and showing a record for edit. in That case i want that if i click the navigate button on the Main Form, the value on the FormC changes according the next or previous move of navigation.
the Navigation buttons is in the FormC in any samples that i found in internet. but i want those be separated.
any sample or idea is appreciated.
In your FormM, make the listview a static member, to do this, go to FormM.Designer.cs, locate the declaration of listview and change it to public static type from private type. After you do this, plenty of errors will be reported in the same file. To fix those, replace all this.listview with only listview.
The above configuration will make your listview accessible from any other form. To access the listview from FormC, user FormM.listview.
Similarly change the Text box/area from FormC to public static. This will make the textbox accessible from FormM.
When you press next and previous buttons, change the selection controls between items and in the SelectedItemChanged action function, put the code to send the selected item to FormC's text box.
Eg: FormC.textbox1.text = {your code to fetch the selected item}