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

Get DevExpress components in runtime using reflection

Last post 8/29/2008 3:54 AM by Faigy Tress. 4 replies.
Page 1 of 1 (5 items)
Sort Posts:
Previous Next
  • 1/28/2008 12:21 PM

    Get DevExpress components in runtime using reflection

    Hi,

         I have a BarManager and BarButtonItems in my XtraForm. Can I get a collection of all components (BarButtonItem, ToolTip, etc....) on XtraForm at runtime using reflection. I wont know the name of any control at runtime since I am trying to develop a class library, which will iterate through controls and components collection, and set some properties on them. Is it possible ?

     

    Thanks !

  • 1/28/2008 1:31 PM In reply to

    Re: Get DevExpress components in runtime using reflection

    Hi!

    Why do you not simple iterate over form.controls collection?

    HTH Wolfgang
    schrieb im Newsbeitrag news:207948@community.devexpress.com...
    Hi,

    I have a BarManager and BarButtonItems in my XtraForm. Can I get a
    collection of all components (BarButtonItem, ToolTip, etc....) on XtraForm
    at runtime using reflection. I wont know the name of any control at runtime
    since I am trying to develop a class library, which will iterate through
    controls and components collection, and set some properties on them. Is it
    possible ?



    Thanks !
  • 1/29/2008 4:59 AM In reply to

    Re: Get DevExpress components in runtime using reflection

    Hi,

          Thanks for your reply ! For your knowledge, many of the so called "controls" are actually components like BarButtonItem and are not included in Controls collection of XtraForm. So I cannot get there reference from controls collection. Hope I am clear now ?

  • 1/29/2008 2:52 PM In reply to

    Re: Get DevExpress components in runtime using reflection

    Hi!

    I have placed this code in the baseclass of my forms within the Activate event. I think, that should help you: Its not nice formatted because i use Outlook Express
    HTH Wolfgang



    Private Sub SysFrmBase_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated

    Static bIsActivated As Boolean = False

    Dim oIcon As Icon

    Dim oSubItem As DevExpress.XtraBars.BarSubItem

    Dim oItem As DevExpress.XtraBars.BarItem

    If Not bIsActivated Then

    bIsActivated = True

    'Debug.Print("Enter SysFrmBase_Activated")

    Dim oContr As Control

    Dim oBardockControl As DevExpress.XtraBars.BarDockControl

    ' Alle XtraEditors mit TooltipController verbinden, Splitter Setzen

    ' suchen des Barmanagers und Deutsche Localisation

    If Not Me.DesignMode Then

    oContr = Me.GetNextControl(Nothing, True)

    Do While Not oContr Is Nothing

    If omBM Is Nothing AndAlso TypeOf oContr Is DevExpress.XtraBars.BarDockControl Then

    oBardockControl = CType(oContr, DevExpress.XtraBars.BarDockControl)

    omBM = oBardockControl.Manager

    If omBM IsNot Nothing Then

    oSubItem = CType(omBM.Items("mnuView"), DB.BarSubItem)

    If Not oSubItem Is Nothing Then

    PrepareStyle(oSubItem)

    End If

    oSubItem = CType(omBM.Items("mnuHelp"), DB.BarSubItem)

    If Not oSubItem Is Nothing Then

    omHelpBar = New DB.Bar(omBM)

    With omHelpBar

    .DockRow = 1

    .DockCol = 99

    .BarName = "HelpBar"

    .Text = "Hilfe"

    .DockStyle = DB.BarDockStyle.Top

    .OptionsBar.AllowDelete = False

    .OptionsBar.AllowQuickCustomization = False

    .OptionsBar.DisableCustomization = True

    .Visible = True

    .ApplyDockRowCol()

    End With

    oItem = New DB.BarButtonItem(omBM, "Hilfe")

    With oItem

    .Name = "mnuShowHelp"

    .Hint = "Hilfe für diese Anwendung (Übersicht)"

    .ItemShortcut = New DB.BarShortcut(Shortcut.F1)

    oIcon = New Icon([Assembly].GetExecutingAssembly.GetManifestResourceStream("Sysdat.Framework.SysWinControls.Help.ico"), 16, 16)

    .Glyph = oIcon.ToBitmap

    End With

    omHelpBar.AddItem(oItem)

    oSubItem.AddItem(oItem)

    Select Case Me.FormType

    Case FormTypeEnum.SingleForm

    oItem = New DB.BarButtonItem(omBM, "Allgemeine Hilfe zu diesem Schirm")

    With oItem

    .Name = "mnuSfrmHelp"

    .Hint = "Allgemeine Hilfe zu diesem Schirm"

    .ItemShortcut = New DB.BarShortcut(Shortcut.CtrlF1)

    oIcon = New Icon([Assembly].GetExecutingAssembly.GetManifestResourceStream("Sysdat.Framework.SysWinControls.XfrmHelp.ico"), 16, 16)

    .Glyph = oIcon.ToBitmap

    End With

    oSubItem = CType(omBM.Items("mnuHelp"), DB.BarSubItem)

    oSubItem.AddItem(oItem)

    omHelpBar.AddItem(oItem)

    Case FormTypeEnum.MultiForm

    oItem = New DB.BarButtonItem(omBM, "Allgemeine Hilfe zu diesem Schirm")

    With oItem

    .Name = "mnuMfrmHelp"

    .Hint = "Allgemeine Hilfe zu diesem Schirm"

    .ItemShortcut = New DB.BarShortcut(Shortcut.CtrlF1)

    oIcon = New Icon([Assembly].GetExecutingAssembly.GetManifestResourceStream("Sysdat.Framework.SysWinControls.XfrmHelp.ico"), 16, 16)

    .Glyph = oIcon.ToBitmap

    End With

    oSubItem = CType(omBM.Items("mnuHelp"), DB.BarSubItem)

    oSubItem.AddItem(oItem)

    omHelpBar.AddItem(oItem)

    End Select

    oItem = New DB.BarButtonItem(omBM, "Info")

    With oItem

    .Name = "mnuInfo"

    .Hint = "Über diese Anwendung"

    '.ItemShortcut = New DB.BarShortcut(Shortcut.F1)

    oIcon = New Icon([Assembly].GetExecutingAssembly.GetManifestResourceStream("Sysdat.Framework.SysWinControls.Info.ico"), 16, 16)

    .Glyph = oIcon.ToBitmap

    End With

    oSubItem.AddItem(oItem)

    End If

    End If

    ElseIf TypeOf oContr Is DevExpress.XtraEditors.BaseControl Then

    Dim oXtraBase As DevExpress.XtraEditors.BaseControl

    oXtraBase = CType(oContr, DevExpress.XtraEditors.BaseControl)

    oXtraBase.ToolTipController = ToolTip

    ElseIf TypeOf (oContr) Is Splitter AndAlso Not Me.DesignMode AndAlso bmRestoreLayout AndAlso Me.FormProperties("OldVersion", 1) = Me.FormVersion Then

    Dim oSplitter As Splitter

    oSplitter = CType(oContr, Splitter)

    oSplitter.SplitPosition = Me.FormProperties(oContr.Name & "SplitterPosition", oSplitter.SplitPosition)

    End If

    If TypeOf (oContr) Is DevExpress.XtraEditors.SplitContainerControl AndAlso Not Me.DesignMode AndAlso bmRestoreLayout AndAlso Me.FormProperties("OldVersion", 1) = Me.FormVersion Then

    Dim oSplitter As DevExpress.XtraEditors.SplitContainerControl

    oSplitter = CType(oContr, DevExpress.XtraEditors.SplitContainerControl)

    oSplitter.SplitterPosition = Me.FormProperties(oContr.Name & "SplitterPosition", oSplitter.SplitterPosition)

    End If

    oContr = Me.GetNextControl(oContr, True)

    Loop

    End If



    <Dev India> schrieb im Newsbeitrag news:208010@community.devexpress.com...
    Hi,

          Thanks for your reply ! For your knowledge, many of the so called "controls" are actually components like BarButtonItem and are not included in Controls collection of XtraForm. So I cannot get there reference from controls collection. Hope I am clear now ?
  • 8/29/2008 3:54 AM In reply to

    Re: Get DevExpress components in runtime using reflection

    Did you find a solution? I have exactly the same problem.

    Thanks!

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