RadToggleSwitch

2 posts, 0 answers
  1. madhu
    madhu avatar
    1 posts
    Member since:
    Jul 2015

    Posted 07 Jul 2015 Link to this post

    hi ,

    how can I remove all the boarders of toggleswitch and I want to change its value only by dragging not by clicking. Is it possible?

  2. Todor Vyagov
    Admin
    Todor Vyagov avatar
    31 posts

    Posted 08 Jul 2015 Link to this post

    Hi,

    Thank you for writing.

    RadToggleSwitch has three main elements: OnElement, OffElement and Thumb. To remove their borders you need to set their DrawBorder properties to false.
    this.radToggleSwitch1.ToggleSwitchElement.DrawBorder = false;
    this.radToggleSwitch1.OnElement.DrawBorder = false;
    this.radToggleSwitch1.OffElement.DrawBorder = false;
    this.radToggleSwitch1.Thumb.DrawBorder = false;

    You can also use Visual Style Builder to edit RadToggleSwitch appearance. See attached image.

    We find the option to change between click and drag-drop mode a reasonable functionality. This is why I have logged this as a feature request in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item. I have also updated your Telerik points.

    For the time being, you can subscribe to the MouseDown and ValueChanging events of RadToggleSwitch and check if mouse position has changed.
    bool isMouseDown = false;
    Point mousePosition;
     
    void radToggleSwitch1_MouseDown(object sender, MouseEventArgs e)
    {
        this.isMouseDown = true;
        this.mousePosition = Control.MousePosition;
    }
     
    void radToggleSwitch1_ValueChanging(object sender, ValueChangingEventArgs e)
    {
        int initialX = this.mousePosition.X;
        int currentX = Control.MousePosition.X;
        int dragOffset = SystemInformation.DragSize.Width;
        if (currentX >= initialX - dragOffset &&
            currentX <= initialX + dragOffset)
        {
            e.Cancel = true;
        }
     
        this.isMouseDown = false;
        this.mousePosition = Point.Empty;
    }

    I hope this information helps.

    Regards,
    Todor Vyagov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top