raddatetimepicker hosted in a toolstrip

4 posts, 1 answers
  1. Mike
    Mike avatar
    9 posts
    Member since:
    Apr 2009

    Posted 02 Jun 2009 Link to this post

    Hi there,

    I can't seem to get a datepicker in a radhostitem (added to a toolstrip programmatically) to sit in line with the other controls on the toolstrip.

    rtsi_Context is a RadToolStripItem

    My code looks like this:-

        RadDateTimePicker dtPicker = new RadDateTimePicker();
                dtPicker.Name = "dtPicker";
                dtPicker.ThemeName = "Office2007Blue";
                RadHostItem hostItem = new RadHostItem(dtPicker);
                hostItem.MinSize = new Size(150, 10);
                hostItem.MaxSize = new Size(150, 10);
                //Add the item to the context menu
                this.rtsi_Context.Items.Add(hostItem);
                //Save a reference for later use.
                rdtp_Rundate = dtPicker;
                rdtp_Rundate.ValueChanged += new EventHandler(rdtp_Rundate_ValueChanged);

    I tried setting various MinSize attributes for the Toolstrip and its various components- other controls aligned themselves appropriately but the radhostitem / datetimepicker appeared "stuck" to the bottom of the RadToolStrip container.

    I put the above code into a button click handler just to make sure that I wasn't attempting to add the control before the toolstrip was initialized correctly, but with the same results.

    Many thanks,
    Mike Renwick
  2. Answer
    Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 05 Jun 2009 Link to this post

    Hello Mike,

    Thank you for writing. I have to admit that we have some layout issues with the current version of RadToolStrip, because it still uses the old layout system. The good news is that we are working on implementing new layouts in the next versions of RadToolStrip, that should address the issues like this. Currently, I have managed to find a work-around by set the Min and Max size for the DateTimePicker element and the HostItem. After that I use PositionOffset property of HostedItem to line up the DateTimePicker with other controls. Please, review the code-block below:

    RadDateTimePicker datePicker = new RadDateTimePicker();  
    datePicker.MinimumSize = new Size(150, 19);  
    datePicker.MaximumSize = new Size(150, 19);  
     
    hostItem = new RadHostItem(datePicker);  
    hostItem.MinSize = new Size(150, 14);  
    hostItem.MaxSize = new Size(150, 14);            
     
    this.radToolStripItem1.Items.Add(hostItem);  
    hostItem.PositionOffset = new SizeF(0, -3); 

    I hope this helps. Do not hesitate to contact me again if you have other questions.

    All the best,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    9 posts
    Member since:
    Apr 2009

    Posted 08 Jun 2009 Link to this post

    Workaround works fine thanks - quite happy to work with workarounds until newer versions, thanks for taking the time to resolve this.
    Regards,
    Mike
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 10 Jun 2009 Link to this post

    Hi Mike,

    Thank you for getting back to me. I am glad that this suits your scenario. Write me back if you need additional assistance.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top