Windows Develop Bookmark and Share   
 index > Windows Forms Designer > TabPage crash in design time with child controls
 

TabPage crash in design time with child controls

Hi all!
I'm trying to implement my custom designer.
Custom designer is loaded inside Visual Studio 2008 like a toolwindow using VSPackage.

My design surface is successfully created and i can set controls inside it.

This is the problem: I have a TabControl that could have many TabPages and inside of each of the many other controls (also custom controls).

No problem when i load controls on the first TabPage (or in a TabControl with only one TabPage).

I've got problems when TabControl has many TabPages, for example 2, and when i try to select one of them. The first one is successfully running with design-time behaviours of controls, but selecting other TabPagesVisual Studio crashes.

Is it a bug?
Am i doing something wrong?

Here some code.

Here i create a new TabPage:
TabPage ctrTabPage= new TabPage(nameCaption);
Here i add it to the TabControl:
ctrTabControl.TabPages.Add(ctrTabPage);             
Here i create a new control (is a custom control):
controlToAdd= (Control)mDesignSurface.CreateControl(controlType);
Here i add the control to the correct tabpage:
ctrTabPage.Controls.Add(controlToAdd);<br/>

I can't understand the problem. All works only for the first tabpage, crash selecting others.

Has anyone an idea?

Thanks!

- Matteo Garzulino -
Matteo Garzulino  Monday, March 30, 2009 10:31 AM
After few test, i realizedi've got the problem onlywith my custom controls, defined like this:

[Designer(typeof(ControlDesigner))]

public class AlphaNumericTextBox: TextBox

{



        public AlphaNumericTextBox()

        {



  

        }



}


No problem with "native" Windows Forms controls.

Anyway, anysuggestion is still welcome! ;)
- Matteo Garzulino -
Matteo Garzulino  Tuesday, March 31, 2009 11:30 AM
After few test, i realizedi've got the problem onlywith my custom controls, defined like this:

[Designer(typeof(ControlDesigner))]

public class AlphaNumericTextBox: TextBox

{



        public AlphaNumericTextBox()

        {



  

        }



}


No problem with "native" Windows Forms controls.

Anyway, anysuggestion is still welcome! ;)
- Matteo Garzulino -
Matteo Garzulino  Tuesday, March 31, 2009 11:30 AM
Ok, I foundthe bug!

On my custom control i had an override of OnEnter().
Inside the override there was this code:
        protected override void OnEnter(EventArgs ea)
        {

            //Other code...
            base.OnEnter(ea);
            if (this.CanFocus)
                this.Focus();
            //Other code...
            Invalidate();
        }
This caused a WindowsMessage Code 8: KILL_FOCUS.

I don't know why, overriding OnEnter() and calling this.Focus() inside it cause this message and then crashing my design-time with custom controls.

If anybodyknows anydetails about KILL_FOCUS, you're welcome

Bye!
- Matteo Garzulino -
Matteo Garzulino  Thursday, April 09, 2009 12:46 PM

You can use google to search for other answers

Custom Search

More Threads

• Lost tool bars while developing a Form in Access 2003
• Getting return codes with the VS2005 WebBrowser Control
• Error message: Index was out of range. Must be non-negative and less than the size of the collection.
• Closing multiple instances of a form
• Form Border Color Design/Appearance
• Display X Y coordinates of moving controls
• ListBox - iterating through selected items
• ComboBox Cell
• DefaultValue attribute on a double property behaves inconsistently with Visual Studio property grid.
• Composite Extender