Change border color is not working

5 posts, 1 answers
  1. Paul
    Paul avatar
    34 posts
    Member since:
    Apr 2017

    Posted 24 Apr Link to this post

    Hello,

    I'm using RadDateTimePicker and I tried to change it's border color but there was no effect.

    Please help me to solve this propblem.

    Thanks

     

     

  2. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 25 Apr Link to this post

    Hi Paul,

    Use the ForeColor property like this:
    var border = radDateTimePicker1.DateTimePickerElement.Children[1] as BorderPrimitive;
    border.ForeColor = Color.Red;

    I hope this helps.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Paul
    Paul avatar
    34 posts
    Member since:
    Apr 2017

    Posted 25 Apr in reply to Dimitar Link to this post

    Hello Dimitar,

    I tried your solution but it didn't have any effects. Please help me to solve my propblem

    My code are:

    public static void ApplyDefaultStyles(this RadDateTimePicker picker)
            {
                picker.Format = DateTimePickerFormat.Custom;
                picker.Margin = new Padding(0);
                picker.AutoSize = false;
                picker.Dock = DockStyle.Fill;
                picker.CustomFormat = MarsConstants.DateFormat;
                picker.Value = DateTime.Now;
                picker.Font = ComponentSettings.DefaultFont;
                picker.ForeColor = ComponentSettings.DefaultForeColor;
                picker.BackColor = ComponentSettings.WhiteColor;
                picker.ThemeName = ComponentSettings.DefaultThemeName;
                picker.EnableTheming = true;
     
                // Arrow button
                picker.DateTimePickerElement.ArrowButton.Border.LeftWidth = 0;
                picker.DateTimePickerElement.ArrowButton.Border.TopWidth = 0;
                picker.DateTimePickerElement.ArrowButton.Border.RightWidth = 0;
                picker.DateTimePickerElement.ArrowButton.Border.BottomWidth = 0;
                picker.DateTimePickerElement.ArrowButton.Fill.BackColor = ComponentSettings.DefaultColor;
                ImagePrimitive imagePrimitive = picker.DateTimePickerElement.ArrowButton.FindDescendant<ImagePrimitive>();
                if (imagePrimitive != null)
                {
                    imagePrimitive.Padding = new Padding(15, 8, 15, 8);
                    imagePrimitive.Image = Properties.Resources.Image054.ResizeImage(UICommon.IconModel.Arrow.Width, UICommon.IconModel.Arrow.Height);
                }
     
                var border = picker.DateTimePickerElement.Children[1] as BorderPrimitive;
                if (border == null) return;
                border.ForeColor = Color.Red;
            }

     

    Also, I's using custom format for date picker based on frequently, maybe it break the format of border?. The logic are:

    For dayly or weekly format:
    dateTimePicker.CustomFormat = "MM/dd/yyyy";
    Or for monthly format
    dateTimePicker.CustomFormat = "MM/yyyy";
    Or for yearly format
    dateTimePicker.CustomFormat = "yyyy";
  4. Answer
    Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 26 Apr Link to this post

    Hi Paul,

    It seems that you are using a theme where the border is not painted. So you need to set the ShouldPaint property as well:
    var border = picker.DateTimePickerElement.Children[1] as BorderPrimitive;
    border.ShouldPaint = true;
    border.ForeColor = Color.Red;

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Paul
    Paul avatar
    34 posts
    Member since:
    Apr 2017

    Posted 26 Apr in reply to Dimitar Link to this post

    Hello Dimitar,

    Thanks you for your help, it have been solved

    Regard,

    Paul

Back to Top