in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Set Properties Of Hosted Control using RibbonControlHost

Last post 09-06-2008 6:56 PM by StrategyMap. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-20-2008 6:00 PM

    Set Properties Of Hosted Control using RibbonControlHost

    So I've fumbled my way through using a RibbonControlHost to put a DateTimePicker on a Ribbon.

    Public Class DTPControlHost
        Inherits C1.Win.C1Ribbon.RibbonControlHost
        Public Sub New()
            MyBase.New(New System.Windows.Forms.DateTimePicker())
        End Sub
    End Class

    Now I can place the control on the ribbon with MyProject.DTPControlHost, but ...

    The DateTimePicker has a format property that I can set (when it is not hosted) by

    DateTimePicker.Format = DateTimePickerFormat.Short

    How can I get at that property in a hosted control, either by settng in the class or in the form load?

  • 06-20-2008 6:11 PM In reply to

    Re: Set Properties Of Hosted Control using RibbonControlHost

    This must be part way there ... lets me set the property but the control displayed doesn't change?

    Public Class DTPControlHost

    Inherits C1.Win.C1Ribbon.RibbonControlHost

    Public Sub New() MyBase.New(New System.Windows.Forms.DateTimePicker())

    End Sub

    Public ReadOnly Property DateTimePicker() As DateTimePicker

    Get

    Return CType(Control, DateTimePicker)

    End Get

    End Property

    Public Property Format() As DateTimePickerFormat

    Get

    Return DateTimePicker.Format

    End Get

    Set(ByVal value As DateTimePickerFormat)

    value = DateTimePicker.Format

    End Set

    End Property

    End Class

  • 06-20-2008 6:20 PM In reply to

    Re: Set Properties Of Hosted Control using RibbonControlHost

    Ah ...

    Have to set the property when using the control like this ...

    DtpControlHost_Start.DateTimePickerControl.Format = DateTimePickerFormat.Short

    You can type

    DtpControlHost_Start.Format = DateTimePickerFormat.Short

    but it won't work ...

    Hope this helps someone else!

  • 06-20-2008 6:39 PM In reply to

    Re: Set Properties Of Hosted Control using RibbonControlHost

    > Public Property Format() As DateTimePickerFormat
    > Get
    > Return DateTimePicker.Format
    > End Get
    > Set(ByVal value As DateTimePickerFormat)

    The next line was incorrect:

    > value = DateTimePicker.Format

    It should be changed to:

    DateTimePicker.Format = value

    > End Set
    > End Property

    Regards,

    -Andrey
  • 06-20-2008 6:46 PM In reply to

    Re: Set Properties Of Hosted Control using RibbonControlHost

    Riiight.

    So if I'd done that correctly, I can use DtpControlHost_Start.Format

    Question - the RibbonControlHost can't be put into a Toolbar in a Group, can it? I'd like to be able to put labels on these but I haven't managed that as yet.

  • 06-20-2008 7:05 PM In reply to

    Re: Set Properties Of Hosted Control using RibbonControlHost

    Yes. RibbonControlHost can't be added to the RibbonToolBar.
    I will add this item to our to-do list.

    Thanks.

    -Andrey
  • 09-06-2008 6:56 PM In reply to

    Re: Set Properties Of Hosted Control using RibbonControlHost

    We have had excellent success using the RibbonControlHost to place a C1FlexGrid inside the ribbon. - Our language is C#

    The reason for the flexgrid is to provide an adaptable column on/off filter for the flexgrid and/or chart that is displayed below the ribbon. Hence the height of the flexgrid is only 2 rows high and does not conflict with the ribbon group maximum height.

    Here is the code...

    using C1.Win.C1FlexGrid;

    using C1.C1Preview;

    namespace StrategyMap

    {

    public partial class frmExportToGrid :Form

    {

    public frmExportToGrid()

    {

    InitializeComponent();

    }

    class FlexGridHost : C1.Win.C1Ribbon.RibbonControlHost

    {

    public FlexGridHost() : base(new C1FlexGrid())

    {

    }

    [
    Browsable(false)]

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

    public C1FlexGrid C1FlexGrid

    {

    get { return (C1FlexGrid)Control; }

    }

    }

     

    #region Global Variables

    --------

     

    Here is the Click event, note that we deal directly with the flexgrid here...

    private void flxColumnFilter_Click(object sender, EventArgs e)

    {

    Point pt = Control.MousePosition;

    pt = flxColumnFilter.C1FlexGrid.PointToClient(pt);

    HitTestInfo hti = flxColumnFilter.C1FlexGrid.HitTest(pt.X, pt.Y);

    int iRow = hti.Row, iCol = hti.Column;

    bool ColIsVisible = Utilities.Convert_ToBoolean(flxColumnFilter.C1FlexGrid[1,iCol].ToString());if (iRow == 0)

    {

    ColIsVisible = !ColIsVisible;

    flxColumnFilter.C1FlexGrid[1, iCol] = ColIsVisible;

    }

    flxExport.Cols[iCol-1].Visible = ColIsVisible;

    }

    ------------

    Here is where we setup the flexgrid...

    flxColumnFilter.Width = 960; // adjust the ribbon group width - note that we dealt with the flexgrid directly to set the group size

    flxColumnFilter.C1FlexGrid.Clear(); // now we need to deal woth the C1FlexGrid object to set special properties

    flxColumnFilter.C1FlexGrid.Redraw =
    false;

    if (flxExport.Rows.Fixed > 0) ColumnNameRow = flxExport.Rows.Fixed - 1;

    flxColumnFilter.C1FlexGrid.AllowSorting = AllowSortingEnum.None;

    flxColumnFilter.C1FlexGrid.Height = 60;

    flxColumnFilter.C1FlexGrid.Rows.Count = 2;

    flxColumnFilter.C1FlexGrid.Rows.Fixed = 1;

    flxColumnFilter.C1FlexGrid.Cols.Count = flxExport.Cols.Count+1;

    flxColumnFilter.C1FlexGrid.Cols.Fixed = 1;

Page 1 of 1 (7 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.