This is a migrated thread and some comments may be shown as answers.

RadToggleSwitch

1 Answer 264 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
madhu
Top achievements
Rank 1
madhu asked on 08 Jul 2015, 02:50 AM

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?

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 08 Jul 2015, 11:10 AM
Hi,

Thank you for writing.

RadToggleSwitch has three main elements: OnElement, OffElement and Thumb. To remove their 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
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
madhu
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or