0

I have a DevExpress SunburstControl displaying folders and their byte sizes, were the sizes are used as the values for the control. Hence, the text in the center displays "Root: 162781888417" (meaning 152 GB) when CenterLabel.TextPattern is set to "Root: {TV}".

Dynamic center label text

However, I want to display this size differently depending on, well, the size...

  • Root size in byte => Shown text
  • 162781888417 => 152 GB
  • 8234489 => 7,85 MB
  • 1047552 => 1 023 kB
  • 40584 => 39,6 kB

I already have code converting between bytes and other units, what I miss is a way to tell the center label to use that conversion code.

So in short: How do I make the center label show different texts based on the value?

Björn Larsson
  • 317
  • 1
  • 5
  • 19

1 Answers1

0

To accomplish this task, manually convert the total value to an appropriate format and assign it to the CenterLabel.TextPattern property. In this example, the BytesToString function converts the number to one of predefined formats (see How do I get a human-readable file size in bytes abbreviation using .NET?)

    private void Form_Load(object sender, EventArgs e)
    {
        long val = 0;
        foreach (var item in sunburstControl1.DataAdapter.Items)
        {
            val += (long)item.Value;
        }
        sunburstControl1.CenterLabel.TextPattern = BytesToString(val);
    }
AlexK
  • 128
  • 5