Cannot set a default item in combobox in certain project - vb.net

In my VB.NET solution in Visual Studio 2015 I have some projects which contains some Windows Forms items. In general I know how to programmatically set a default item in a combobox control by using ComboBox1.SelectedIndex = 0 instruction. However this instruction do not work in one of my projects and my combobox is always blank when program runs. I also cannot add programmatically new items to combobox in this project, I can do it only using Properties sidebar.
My program runs normally, Visual Studio do not see any errors, instructions which concerns my combobox are executed but don't affect it. In other projects everything works well.
Have you ever encountered something like this? Maybe I've unconsciously changed some options in this project and that's why the problem occur?
EDIT:
Problem solved. I didn't noticed that during copying some code I accidently also copied InitializeComponent() instruction. Without this duplicated initialize instruction everything is working well and I have ability to manage default value of my combobox correctly.

Related

How to find a form from many forms in vb6 on a existing project

I am working on a old project of vb6 which has hundreds if forms. I am able to run the application and have to fix a runtime error in a form which pop up. I don't know the name of the form and only have visual reference. I tried using debug but It has continues SQL statements running in a loop. Any advice is appreciated.
Thanks.
Search the code for the form caption, or the labels of controls on the form, using visual studio's "find in files" or simlar function of your favourite editor.
If the caption is set in the form design, this will take you to the .frm file the form is stored in. You can open this in Notepad or another editor to get the name of the class (which is usually the same as the filename).
If the caption is set in code, you can place a breakpoint on that line. Again, this will lead you to the code which instantiates the form.

vb.net 2008 express: Two textboxes in a custom control

I'm making a custom control in VB.net 2008 Express. Without getting into the details, I am able to duplicate the issue as follows:
Make a blank custom control. Stick two textboxes on it. Don't add any code.
Run it and click the second textbox. (Don't click the first.) The text cursor appears of course.
Now Type... Although the text cursor moves within the second textbox, the text you type appears in the first textbox, not the second one.
I have found that this issue depends on the tab order of the controls. Whichever textbox is first in the tab order gets text typed in the other.
I have also found that if you press [Tab] to set focus on either textbox, the problem goes away.
QUESTIONS:
1) Is this a known bug in .net? (Specifically 2008 Express)
2) Will this phenomenon carry over when the custom control is brought into a larger project?
I followed the steps above and was able to reproduce it when I started with a Windows Form Control Library and ran it inside the UserControl TestContainer. I test this in Visual Studio 2008 Professional.
However, when I placed the user control inside a form in a separate Windows Forms Application project, the issue did not occur. So I'd think it's safe to say that this won't be an issue when the user control is used in another project.

Deleting menu item results index error ("source not found")

In VB.Net 2010, whenever I delete a menu item on a Windows Form (a Mainmenu1 object), an exception is thrown at run-time suggesting that there is an index value missing -- essentially a "source not found" error. Do I need to go into the Mainmenu1 object on the bottom of the Form at design time and do something? (BTW, I have also tried deleting the source code for the menu item, and then the menu item, and the exception is still thrown).
Basically, something is occurring that is not allowing me to simply delete a menu item, and get a successful run thereafter.
I had this problem. The simple fix is to restore the menu by clicking undo. Then run the code to make sure it still works. When you have done this, CLOSE visual studio. Then open VS and load your project. Delete the item from the menu and run the project. Everything should be fine
I think you need to specify whether you were trying to delete the menu or menu item during run time, or during design time.
You said, an exception, indicating an index value was missing, thrown at run time. I think it might be depending on how you deleted the menu item. You didn't mention how you deleted the menu item.
Normally, when you choose a menu item from a menu at design time, and press the Delete key, it disappeared. And, the program still works fine.
And, another possibility, is that your form window designer and the background designer code is not properly synced.
You might know that, every .NET form objects, have their background designer code, which serves as a schema for everything on the form.
When you add a button onto the form, the Visual Studio add a line of code in the designer code file (normally if your form name is form1, the designer code file is form1.designer.vb or cs or whatever). When you change the background colour of the button, designer code file add a line of code to set the button's background colour.
So, you see, in your case, when you delete the menu item, your designer code file probably didn't successfully remove the code relating to that menu item. So, it throws an exception at run time.
Maybe, it's because of your Visual Studio installation.
So, my suggestion is, you should try debugging the project, line by line, by running the project with F6 or F11 (sorry, I don't remember the exact key, but you can find it in the Debug menu).
I hope I made a good sense for your problem!

Error in Silverlight 4 app: Event handler 'True' not found on class 'MyApplication.MainPage'

Has anyone ever come across this one?
One second everything works ok, then I get this error out of nowhere.
It doesn't make sense, and there's no code/xaml out of place.
Bing/Google searches come up empty.
Visual Studio 2010
Silverlight 4 application
VB.NET
Found the problem. If you want to specify that a checkbox is checked, set the IsChecked property to True, and not the Checked property.
This is correct:
Auto Save
This will make your life miserable:
Auto Save
My biggest complaint with Silverlight is this kind of problem. Visual Studio didn't bring me to this line, let alone this property setting. I had to manually comment out code, then individual blocks of xaml to figure it out.

Corrupt forms, not displaying in "startup form"?

In properites>Application>"Startup form" combobox, in my VS VB.NET project, I see only 2 forms listed, while my application has 6 forms. Does this mean something is corrupt?
I tried to make a new project, then copy only the old vb files into this new project. But still only those two (of 6) forms show up in the "Startup form" combo box.
Well, that's pretty odd. This list is almost certainly filled from the project file, the <SubType> element should be significant. But you eliminated that possibility by recreating the project file from scratch. I can't see how a property on a form would make it disappear from the list.
One thing you could try is editing the My Project\Application.myapp file with Notepad. Copy the solution first and make sure it isn't loaded in VS. Change the <MainForm> element to one of the forms that isn't listed. Load the project and see what is shown in the project property page and if anything breaks when you compile it.