Hello Roland.

Thanks for the tips + links, I will study it.

But all this must take attention to sorting.
The size column is in a TStringGrid and the sorting must be adapted for numbers.

For example, '100 KB' will be < '99 KB' because it sort with the first string, 
even if it is a number.

The trick that I using is to add spaces before the numbers to get always the 
same length (15 characters),
example: '100 KB' > ' 99 KB'
But for playing with different units (KB, MB, B), maybe add a symbol  before 
all the space added.
In that case, the space '  ' for B, then maybe '_' for KB and '~' for MB.

Example:

'     100 B' <  '_    100 KB' <  '~    100 MB'

Have a perfect day.

Fre;D



________________________________
De : Roland Chastain <[email protected]>
Envoyé : samedi 29 août 2020 07:15
À : [email protected] 
<[email protected]>
Objet : Re: [MSEide-MSEgui-talk] New extended MSEFileDialog component.

Good.

About file size formatting, do you know this library?
ByteSizeLibPascal <https://github.com/Xor-el/ByteSizeLibPascal>

Here is an interesting example taken from the documentation.

// ==========
uses
  SysUtils, uByteSize;

var
  b: TByteSize;

begin
  b := TByteSize.FromKiloBytes(0.5);
  WriteLn(b.ToString); // 512 B
  WriteLn(TByteSize.FromKiloBytes(1000).ToString); // 1000 KB
  WriteLn(TByteSize.FromKiloBytes(1024).ToString); // 1 MB
end.
// ==========

Maybe you could use it (it's one unit).




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to