in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

User control does not appear in PanelGroup / ControlGroup

Last post 8/28/2008 3:55 PM by Oliver Dracus. 9 replies.
Page 1 of 1 (10 items)
Sort Posts:
Previous Next
  • 8/24/2008 3:50 PM

    User control does not appear in PanelGroup / ControlGroup

     Hi,

    probably stupid questions but...

    I create one form and places PanelControl on it, then I created one user control (tried DevExpress UserControl and Microsoft User Control) on which I places NavBar and later I tried control only with Microsoft button.

    On master form with PanelControl I wrote following code

    Private 

    ctrlMyTest As New  ctrlTest

    Private

    Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    InitializeComponent()
    DevExpress.Skins.SkinManager.EnableFormSkins()

     

    With ctrlNBHotelPlusMain
          .Parent = PanelControl1
         
    .Dock = DockStyle.Fill
      
    End With

     

    Me.PanelControl1.Controls.Add(ctrlNBHotelPlusMain)
    ctrlNBHotelPlusMain.Show() 'I tried also without this line

     

    End Sub

    and my problem is that my user control is not shown when I open my form.
    In user control I do not have a single line of code.

    Any idea what I should do?

    Thanks,
    Oliver

  • 8/24/2008 6:14 PM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

    Where is the ctrlNBHotelPlusMain object being constructed?  Are you trying to add the "type" to the panel, or an instance of that type?
     
  • 8/25/2008 12:46 AM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

    My mistake. Code should look like:

    Private ctrlMyTest As New  ctrlTest

    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


     InitializeComponent()
     DevExpress.Skins.SkinManager.EnableFormSkins()

     

     With ctrlMyTest
      .Parent = PanelControl1
      .Dock = DockStyle.Fill
     End With
     

     Me.PanelControl1.Controls.Add(ctrlMyTest)
     ctrlMyTest.Show() 'I tried also without this line

    End Sub

     


    Best regards,
    Oliver

     

  • 8/28/2008 12:56 AM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

     Anybody?

  • 8/28/2008 1:39 AM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

    I am not sure how to answer???
     
    I program in C# and in C# the InitializeComponent() method is in the constructor, not the Load event. I would have suggested moving the code to the Load event which occurs after the form has initialized.
     
    Maybe I am whacko, but in VB isn’t there a constructor that is separate from the Load event?
     
    Is your code posted accurately?
     
    Anybody else know VB better than I?
     
    "Oliver Dracus" wrote in message news:232716@community.devexpress.com...

     Anybody?



    http://community.devexpress.com//forums/p/68274/232716.aspx#232716

    Trevor Westerdahl - DX Squad
    BLOG: http://trevorunlocked.blogspot.com/
  • 8/28/2008 11:05 AM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

     You're right, Trevor. VB does have a constructor for each form. Just like in C/C#, each and every VB form is an object, with a New() constructor. This is where the InitializeComponent() method  is located. This is definitely the area to handle any custom initializations.

    Russ Yeagley

  • 8/28/2008 12:25 PM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

    > You're right, Trevor. VB does have a constructor for each form. Just like in C/C#, each and every VB form is an object, with a New() constructor. This is where the InitializeComponent() method  is located. This is definitely the area to handle any custom initializations.
     
    Okay - so why is InitializeCompenent() within the Load event handler and not in the New method (constructor)?
     
    I don’t see how the form would load properly if InitializeComponent() is moved from New() to the Load event handler - or I may just be missing something.
     
     
    Anyway, it seems like a very simple test project with something going wrong. Perhaps - Oliver - you can zip up a small sample solution and post it to the forum here, then perhaps someone could help you.... or... you could send it in to support and I am they could help.
     
    Trevor Westerdahl - DX Squad
    BLOG: http://trevorunlocked.blogspot.com/
  • 8/28/2008 1:24 PM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

     Hi,

    well when I copied code I copied with my test where InitializeComponents are in Load method. Before that I tried same thing with New and also did not get any results. User controls was not shown :(
    I will try one more thing and then let you know how it went.

    Best regards,
    Oliver

  • 8/28/2008 3:46 PM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup & class (form) constructors

    To best illustrate my point, I'll display a whole lot of code that declares classes, has class constructors, handles global form and component skinning and deals with the user clicking the 'x' close button on a form, in Visual Basic 2008. If you have the Developer's Express Enterprise edition, you should be able to use the code exactly as you see it. Aside from getting eyestrain, I hope this will help you to see that the constructor is a separate entity from the form load event.

    And, if you see any code you would like to use in your own programs, please help yourself!

    Russ

    Here goes............................


        #Region " Options "
        Option Explicit On
        Option Strict On
        Option Infer Off
        #End Region ' Options

        #Region " Imports "
        #Region " Windows "
        Imports System
        Imports System.IO
        Imports System.Text
        Imports System.Data
        Imports System.DateTime
        Imports System.Data.OleDb
        Imports System.Diagnostics
        Imports System.IO.Directory
        Imports System.Globalization
        Imports System.Data.SqlClient
        Imports Microsoft.VisualBasic
        Imports System.Windows.Forms
        Imports System.Drawing.Printing
        Imports System.Text.RegularExpressions
        #End Region                   ' Windows

        #Region " DevExpress "
        Imports DevExpress.XtraEditors
        Imports DevExpress.Utils

        ' I usually load the whole skins library!

        Region " Developer's Express Skins "
        Imports DevExpress.Skins
        Imports DevExpress.Skins.Skin
        Imports DevExpress.Skins.TabSkins
        Imports DevExpress.Skins.BarSkins
        Imports DevExpress.Skins.FormSkins
        Imports DevExpress.Skins.GridSkins
        Imports DevExpress.Skins.VGridSkins
        Imports DevExpress.Skins.RibbonSkins
        Imports DevExpress.Skins.NavBarSkins
        Imports DevExpress.Skins.CommonSkins
        Imports DevExpress.Skins.SkinManager
        Imports DevExpress.Skins.EditorsSkins
        Imports DevExpress.Skins.DockingSkins
        Imports DevExpress.Skins.NavPaneSkins
        Imports DevExpress.Skins.ReportsSkins
        Imports DevExpress.Skins.SchedulerSkins
        Imports DevExpress.Skins.TabSkinProperties
        Imports DevExpress.Skins.SkinManagerHelper
        #End Region                   ' Developer's Express Skins
        #End Region                   ' DevExpress
        #End Region                   ' Imports

        ' In the global declarations module, place:

        Friend Const FRMTITLE As String = "     Trojans Training Schedule: "
        Friend Const PROB As String = "Problem in "  ' use in error message boxes

        #Region " MessageBox Buttons "
        Friend Const MBBOK As MessageBoxButtons = MessageBoxButtons.OK
        Friend Const MBBYN As MessageBoxButtons = MessageBoxButtons.YesNo
        Friend Const MBBOC As MessageBoxButtons = MessageBoxButtons.OKCancel
        Friend Const MBBRC As MessageBoxButtons = MessageBoxButtons.RetryCancel
        Friend Const MBBYC As MessageBoxButtons = MessageBoxButtons.YesNoCancel
        Friend Const MBBAR As MessageBoxButtons = MessageBoxButtons.AbortRetryIgnore
        #End Region ' MessageBox Buttons

        #Region " Windows Forms Dialogs Results "
        Friend Const WFDNO As Windows.Forms.DialogResult = DialogResult.No
        Friend Const WFDYES As Windows.Forms.DialogResult = DialogResult.Yes
        Friend Const WFDOK As Windows.Forms.DialogResult = DialogResult.OK
        Friend Const WFDRETRY As Windows.Forms.DialogResult = DialogResult.Retry
        Friend Const WFDNONE As Windows.Forms.DialogResult = DialogResult.None
        Friend Const WFDABORT As Windows.Forms.DialogResult = DialogResult.Abort
        Friend Const WFDIGNORE As Windows.Forms.DialogResult = DialogResult.Ignore
        Friend Const WFDCANCEL As Windows.Forms.DialogResult = DialogResult.Cancel
        #End Region ' Windows Forms Dialogs Results

        #Region " MessageBox Icons "
        Friend Const MBISTOP As MessageBoxIcon = MessageBoxIcon.Stop
        Friend Const MBIHAND As MessageBoxIcon = MessageBoxIcon.Hand
        Friend Const MBINONE As MessageBoxIcon = MessageBoxIcon.None
        Friend Const MBIEROR As MessageBoxIcon = MessageBoxIcon.Error
        Friend Const MBIWARN As MessageBoxIcon = MessageBoxIcon.Warning
        Friend Const MBIASTE As MessageBoxIcon = MessageBoxIcon.Asterisk
        Friend Const MBIQUES As MessageBoxIcon = MessageBoxIcon.Question
        Friend Const MBIEXCL As MessageBoxIcon = MessageBoxIcon.Exclamation
        Friend Const MBIINFO As MessageBoxIcon = MessageBoxIcon.Information
        #End Region ' MessageBox Icons

        #Region " MessageBox Default Buttons "
        Friend Const MBDB1 As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1
        Friend Const MBDYES As MessageBoxDefaultButton = MBDB1
        Friend Const MBDB2 As MessageBoxDefaultButton = MessageBoxDefaultButton.Button2
        Friend Const MBDNO As MessageBoxDefaultButton = MBDB2
        Friend Const MBDB3 As MessageBoxDefaultButton = MessageBoxDefaultButton.Button3
        #End Region ' MessageBox Default Buttons

        ' Developer's Express screen themes (skins) it will be used with 'mainTheme' variable
        ' to allow the user to change the theme to any listed below, no matter how many forms
        ' and components...
        '
        #Region "Screen Themes"                  
        Friend Const SCRCARA As String = "Caramel"
        Friend Const SCRMONE As String = "Money Twins"
        Friend Const SCRLILI As String = "Lilian"
        Friend Const SCRASPH As String = "The Asphalt World"
        Friend Const SCRIMAG As String = "iMaginary"
        Friend Const SCRBLAC As String = "Black"
        Friend Const SCRBLUE As String = "Blue"
        Friend Const SCRCOFF As String = "Coffee"
        Friend Const SCRLIQS As String = "Liquid Sky"
        Friend Const SCRLLIQ As String = "London Liquid Sky"
        Friend Const SCRGLAS As String = "Glass Oceans"
        Friend Const SCRSTAR As String = "Stardust"
        Friend Const SCRX08B As String = "Xmas 2008 Blue"
        Friend Const SCRVALN As String = "Valentine"
        Friend Const SCRMCSK As String = "McSkin"
        Friend Const SCRO7BU As String = "Office 2007 Blue"
        Friend Const SCRO7BL As String = "Office 2007 Black"
        Friend Const SCRO7SI As String = "Office 2007 Silver"
        Friend Const SCRO7GR As String = "Office 2007 Green"
        Friend Const SCRO7PI As String = "Office 2007 Pink"
        #End Region ' Screen Themes

        Friend Const PROB As String = "Problem in "   ' used in Try-Catch-End Try blocks

        Friend isClosing As Boolean = False                ' used to deal with Form_Closing Event

        Friend emptStr As String = String.Empty           ' empty string, shorter than String.Empty

        Friend mainTheme As String = SCRMONE       ' set the theme for skinning - Money Twins
        '
        ' with this variable, you can allow the user to change to the skin of their choice
        ' see EnableSkins() below

        'end global declarations ---------------------------------------------------------

        '---------------------------------------------------------------------------------
        ' Sub Main() with an easy way to prepare to globally set skinning
        '---------------------------------------------------------------------------------

        Friend Class Program
       
        Private Sub New()        ' provide a constructor
        End Sub
         
        ' use Sub Main() to begin the application ----------------------------------------

        <STAThread()> _
           Shared Sub Main()

              DevExpress.Skins.SkinManager.EnableFormSkins()
              DevExpress.UserSkins.BonusSkins.Register()
              DevExpress.UserSkins.OfficeSkins.Register()
              DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = mainTheme
              DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(mainTheme)
              SetCompatibleTextRendering()
              Application.EnableVisualStyles()

              ' Please note: SetCompatibleTextRendering() must be called before any form is loaded
              Application.SetCompatibleTextRenderingDefault(False)
           
              Application.Run(New thisForm())

           End Sub

        End Class    ' end of class Program with Sub Main() embedded inside

        '--------------------------------------------------------------------------------- 

        ' Here is the thisForm class called above in Sub Main()
        '   use this code if you have Developer's Express forms
       
        Public Class thisForm : Inherits XtraForm

        ' put your constructor just below the class declaration
        '
        Public Sub New()
           '
           ' Required for Windows Form Designer support
           '
           InitializeComponent()
           '
           ' put any other custom declarations here
           '
        End Sub

        ' next, move on to the form load event
        '
        '---------------------------------------------------------------------------------  
        ' Form_Load - Please note: EnableSkins() should be called when each form loads.
        '---------------------------------------------------------------------------------

        Private Sub FormLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                                                                                                Handles MyBase.Load
           EnableSkins()                                ' set skinning for the form
           Me.Text = FRMTITLE & "thisForm"
           isClosing = False                           ' part of form closing strategy
           KeepFormSize(Me)                       ' keep form size static - if you wish

        End Sub

        '---------------------------------------------------------------------------------

        Friend Sub SetCompatibleTextRendering()

           Try
               Application.SetCompatibleTextRenderingDefault(False)

           Catch ex As Exception
               XtraMessageBox.Show(ex.Message, PROB & "SetCompatibleTextRendering", MBBOK, MBISTOP)
           End Try

        End Sub

        '---------------------------------------------------------------------------------

        Friend Sub EnableSkins()

            Try

               DevExpress.Skins.SkinManager.EnableFormSkins()
               DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged()
               DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = mainTheme
               DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(mainTheme)
               Application.EnableVisualStyles()

            Catch ex As Exception
               XtraMessageBox.Show(ex.Message, PROB & "EnableSkins", MBBOK, MBIWARN)
            End Try

        End Sub 

        '---------------------------------------------------------------------------------

        Friend Sub KeepFormSize(ByVal formName As Form)

            Try

               formName.MinimumSize = formName.Size                             ' cannot be sized smaller
               formName.MinimizeBox = False                                             ' show no minimize box
               formName.MaximumSize = formName.Size                             ' cannot be sized larger
               formName.MaximizeBox = False                                             ' show no maximize box
               formName.StartPosition = FormStartPosition.CenterScreen   ' draw in middle of the screen

            Catch ex As Exception
               XtraMessageBox.Show(ex.Message, PROB & "KeepFormSize", MBBOK, MBISTOP)
            End Try

        End Sub

        '---------------------------------------------------------------------------------
        ' For the FormClosing strategy: In the Form_Closing, place:
        '---------------------------------------------------------------------------------

        Private Sub thisForm_FormClosing(ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs) _
                                   Handles Me.FormClosing
           Try

              If isClosing = True Then        ' the menu exit item was clicked
                                                            ' user answered question with yes
                                                            ' in the menu or button exit command
                                                            ' Do any pre-close processing
                 e.Cancel = Nothing             ' set the cancel flag to NULL
                 Application.Exit()                 ' move out
              Else                                       ' isClosing = False from file exit click
                                                            ' user clicked x on right of form
                                                            ' need to show the exit question
                 If XtraMessageBox.Show("Close the Form?", FRMEXIT, MBBYN, MBIQUES) = WFDYES Then

                                                            ' Do any pre-close processing
                    e.Cancel = Nothing          ' set the cancel flag to NULL
                    Application.Exit()              ' move out
                 Else                                    ' the user doesn't want to exit
                    e.Cancel = True              ' set the cancel flag to true
                 End If                                  ' End If XtraMessageBox.Show(...
              End If                                     ' End If isClosing = True

          Catch ex As Exception                        
              XtraMessageBox.Show(ex.Message, PROB & "thisForm_FormClosing", MBBOK, MBIWARN)
           End Try

        End Sub

        '---------------------------------------------------------------------------------
        ' For the FormClosing strategy: In the menu exit or exit button click event, place:
        '---------------------------------------------------------------------------------

        Private Sub mnuFileExit_ItemClick(ByVal sender As System.Object, _
                                        ByVal e As DevExpress.XtraBars.ItemClickEventArgs) _
                                        Handles mnuFileExit.ItemClick
           Try
              '    ask the user the exit question when menu item or button is clicked.
              '
              If XtraMessageBox.Show("Close the Attendee Data Entry Form?", FRMEXIT, MBBYN, MBIQUES) _
                                                                                         = WFDYES Then
                                                                                         
              isClosing = True                        ' they said 'yes' they want to exit
              Me.Close()                                ' start the ball rolling
                                                               '   this will activate the first isClosing = True
                                                               '   in the Form_Closing event
            Else                                            ' the user doesn't want to exit
               isClosing = False                     ' set the global exit flag to False
            End If                                          ' End If XtraMessageBox.Show(...

           Catch ex As Exception
              XtraMessageBox.Show(ex.Message, PROB & "mnuFileExit_Click", MBBOK, MBIWARN)
           End Try

        End Sub

  • 8/28/2008 3:55 PM In reply to

    Re: User control does not appear in PanelGroup / ControlGroup

    Problem solved :).

    After I deleted current PanelControls and add them again with adding user controls to panels everything work ok.

    Best regards,
    Oliver

Page 1 of 1 (10 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED