0

I have developed a GUI where in I need to update some(4) parameters in a ListBox.I am usind the following code to do this.

CString tmp;
tmp.Format("%4d %4d %4d",a,b,c);
 listBx.AddString(tmp);

a,b and c are integers.listBx gets updated every 1 sec.
But I am not getting the output in a formatted manner.
Suppose if a is variable between 2 digit and 4 digit numbers the entire string gets distrubed.both b and c columns move left or right depending upon no, of digits in a.
How can this be solved.
Thanks in advance

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by MrSpigot
0

Thanks,
But I tried even that.but in vain.When I am printing that to the console I can see the alignment but when I convert (Format) it to CString I am missing the alignment.Could there be any other fix...

1

Items in a list box are not generally displayed in a fixed width font. So the length of the string will vary with different numbers, even though the number of characters is constant.
You could modify the list box to use a fixed font, though you might not find that easy and it isn't always desirable to see fixed fonts on GUIs.
A better solution would be to use a list control with 3 columns instead of a simple list box. The numbers will then be aligned by the control.

Votes + Comments
Good suggestion :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.