SelectedIndex value of combobox disappears from designer [duplicate] - c#

This question already has answers here:
Manual editing of *.designer.cs file
(5 answers)
How to modify code in designer.cs
(1 answer)
The *Design.cs file will reset automatically and delete the manually writed codes?
(1 answer)
Closed 2 years ago.
In C#, I have some comboboxes functioning as dropdown lists. The first value in the collection is the one I want to show as default to the user. Therefore, I added a line to the designer file, so that upon load, first value, aka index 0, is shown.
combobox1.SelectedIndex = 0;
It works! I do the same for every other combobox in my app, however, this keeps disappearing from the designer file. How can I fix this?
Thanks in advance.

As mentioned in comments:
The designer file is not for you to edit - there is a comment in the file to that effect. The Designer is constantly rewriting the designer file to reflect changes it needs to make. Move your code to someplace such as the form load event
As the programming noob I am, I overlooked adding an OnLoad method with the selectedindex for each combobox. That solved my problem!

Related

How to re-add a tab after removing it in c# [duplicate]

This question already has answers here:
Hiding and Showing TabPages in tabControl
(21 answers)
Closed 3 years ago.
Maybe i am going the wrong way with this but for an application i make use of 2 TabControls.
The left one contains a menu the right one a bit of a preview page of how things wil be. The right tab menu i have the tab page selection hidden(Only able to hide them all not an individual) so they can't manually switch, depending on the left tab the right tab switches with it accordingly.
But here is the issue i am having, the left tab should only display certain tabs depending on account type. So is there a way to hide certain tabs?
If i remove them i can't get them back, so hiding would be preferential, or if possible perhaps move them to the right tabcontrol where they can't be manually selected?And move them back if the user changed?
I don't think I understand your question 100% but maybe do something like this to store a copy of your TabPage.
var tempTabControl = new TabControl();
tempTabControl.TabPages.Add(TC_NAME);
mainTabControl.TabPages.Remove(TC_NAME);

Best way to modify items in ObservableCollection with a form [duplicate]

This question already has answers here:
WPF ObservableCollection Edit Mode
(4 answers)
Closed 7 years ago.
I have an application that collects data in the background, displays data with one window, and has another form that can be used to update data objects. Data is stored in an observable collection that can be accessed application wide.
I would like to know the best way to edit the data with one form (the form must have an option to save the data, or cancel editing), and have the other window still display current data.
My idea right now is to have the form bind to a copy of the data object being edited, and then only replace the object in the ObservableCollection when the user confirms the changes. But I would like to know if there is a better way to go about this?
I would have the object expose both inprogess and final values. Bind to the final and have a method in the object to copy inprogress to final.

Can I display links in a ListView's detail mode? [duplicate]

This question already has answers here:
Can I display links in a ListView's detail mode?
(5 answers)
Closed 9 years ago.
In my windows application, I have a listview, which contains two columns. One of the subitem in a row contains the data as below.
"Failed testcase path=C:\temp\test.jpg"
I need to provide hyperlink to only C:\temp\test.jpg. If I click on the same, it should open the corresponding image.
I tried by changing the property HotTracking to true.
listView1.HotTracking = true;
But it shows hyperlinks to all the rows in listview.
Is there a way to achieve this?
Use ObjectListView -- an open source wrapper around a standard ListView. It supports links directly:
This documents the simple process and how you can customize it.

Best way to insert control into tab order? [duplicate]

This question already has answers here:
Setting the TabIndex property of many form controls in Visual Studio?
(4 answers)
Closed 9 years ago.
If there is an existing tab order on a large set of controls on a form, what is the easiest way to insert a control in the middle of that tab order without having to re-number the tab order of all the controls after the one inserted?
Visual Studio has a tool for that. It allows you to click the taborder you want - by selecting the control in the order you want:
the blue boxes(with white numbers) are the current taborder, and white boxes are the new taborder.
This might be helpful to you.
(new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
Follow this link>
http://www.codeproject.com/Articles/8406/Automatic-Runtime-Tab-Order-Management-for-Windows

.NET. How to hack OpenFileDialog? [duplicate]

This question already has an answer here:
Closed 12 years ago.
Possible Duplicate:
changing button text in OpenFileDialog in C#.net
Have a good day,
Is there a way to override Open button in .NET OpenFileDialog?
I need to Change the button text and override OnClick event.
If this is not possible can I put a custom button over the Open button (but at the most top X order)?
--
BR
Murat
Everything is possible, but the question is what You really want to achieve by this strange behavior ?
What's wrong with standard usage of the OK button ? Where You pick the path and do what You want to.

Categories