check it out, weird error from combo box
This is weird, I even started a new project to prove I'm not doing anythign wrong. When you have visual styles enabled, if you load a form using the ShowDialog method in the selectedIndexChanged event of the combo box, you get an error (I'm sure it has nothing to do with the combo box, it's just a situation when it happens. Apparently it has to do with visual styles and the ShowDialog method). Try this:
In a new project add a combo box to a form (called Form1 here) and add a bunch of items into the combo box. Then add this code:
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Application.EnableVisualStyles()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim frm As New Form1
frm.ShowDialog()
End Sub
Run the app. Now select an item from the combo box and a new form pops up, repeat this again and then close the second form that pops up and wait a few seconds,... dont you get an error?
Re: check it out, weird error from combo box
I just ran into this problem today. I know its an old thread.. but I figured I would post since I was trying to find a solution and apparently there is none (other than NOT using enablevisualstyles)
I did find out that MS at least DOES know about it.. although I guess they are not fixing it?
I know that there is going to be another service pack for VS.NET 2003 in the second 1/4 of this year.
from MSKB
Quote:
You may receive the same error message that is discussed in the "Symptoms" section when you use the ShowDialog method to open a form. To work around this behavior, use the Show method instead of the ShowDialog method.
hardly a workaround being that show and showdialog have totally different behavior..
Re: check it out, weird error from combo box
Did you try calling InitCustomControlsEx as the first step of your app?
(I don't use Windows eXtreme Paintset so can't test it myself)
Re: check it out, weird error from combo box
Quote:
Originally Posted by Merrion
Did you try calling InitCustomControlsEx as the first step of your app?
(I don't use Windows eXtreme Paintset so can't test it myself)
I don't know what that is? Is it an API function or something?
The only solutions MS has provided is to do what I said above, or use a manifest file instead of Application.EnableVisualStyles