How to Programmatically Trigger LabelFormatting Event on RadTrackBar?

1 Answer 6 Views
TrackBar
Jacky
Top achievements
Rank 1
Jacky asked on 01 Jul 2025, 07:04 AM
I'm working with RadTrackBar in WinForms, and I'm trying to dynamically refresh the labels by triggering the LabelFormatting event after programmatically changing properties like Minimum, Maximum, or LabelStyle.

However, calling methods like Invalidate() and Update() does not seem to re-trigger the LabelFormatting event or force label reconstruction.

As a temporary workaround, I'm using this code:
radTrackBar1.Maximum += 1;
radTrackBar1.Maximum -= 1;
It does trigger LabelFormatting, but honestly feels like a hack. I'm hoping there's a more reliable or cleaner way to rebuild the labels or directly invoke the formatting logic.

I've attached a screenshot to illustrate my use case and how the labels are styled after formatting.

Does anyone know of an official or recommended approach?

pic

1 Answer, 1 is accepted

Sort by
1
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 02 Jul 2025, 11:00 AM

Hello, Jacky,

To programmatically trigger the LabelFormatting event and refresh the labels on RadTrackBar, you can call the FormatLabels() for both BottomScaleElement/TopScaleElement in the following way:

this.radTrackBar1.TrackBarElement.BodyElement.ScaleContainerElement.BottomScaleElement.LabelContainerElement.FormatLabels();
this.radTrackBar1.TrackBarElement.BodyElement.ScaleContainerElement.TopScaleElement.LabelContainerElement.FormatLabels();

Methods like Invalidate() and Update() will not trigger the LabelFormatting event, as they only repaint the control and do not rebuild the labels.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

      Regards,
      Nadya | Tech Support Engineer
      Progress Telerik

      Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

      Tags
      TrackBar
      Asked by
      Jacky
      Top achievements
      Rank 1
      Answers by
      Nadya | Tech Support Engineer
      Telerik team
      Share this question
      or