Listbox help
-
Hi all, I posted this a couple days ago but didn't get any response. Thought i would try to post it again and see if someone could help. Wanted to know if it is possible to both pad a hex numbers with leading 0's and also format the width of the message. I have a string and i just concat a hex number to it. I just want to space out the numbers so that they will line up with the next string added, so that it has the look of a table. Right now i am padding the hex number like this:
int myString = 10005; int myString2 = 20003; testStr.Format("%03X" , myString); Str += testStr; testStr.Format("%03X" , myString2); Str += testStr; Listbox.AddString(Str);
I know if i take away the 0, then it will set the width, but i need to do both. CAN THIS BE DONE? thanks in advance. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
-
Hi all, I posted this a couple days ago but didn't get any response. Thought i would try to post it again and see if someone could help. Wanted to know if it is possible to both pad a hex numbers with leading 0's and also format the width of the message. I have a string and i just concat a hex number to it. I just want to space out the numbers so that they will line up with the next string added, so that it has the look of a table. Right now i am padding the hex number like this:
int myString = 10005; int myString2 = 20003; testStr.Format("%03X" , myString); Str += testStr; testStr.Format("%03X" , myString2); Str += testStr; Listbox.AddString(Str);
I know if i take away the 0, then it will set the width, but i need to do both. CAN THIS BE DONE? thanks in advance. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
NewHSKid wrote: Wanted to know if it is possible to both pad a hex numbers with leading 0's and also format the width of the message. Sure: You know the width of your column, the length of your hex number, and the difference of both is the number of leading '0' you have to prepend.
Who is 'General Failure'? And why is he reading my harddisk?!?
-
Hi all, I posted this a couple days ago but didn't get any response. Thought i would try to post it again and see if someone could help. Wanted to know if it is possible to both pad a hex numbers with leading 0's and also format the width of the message. I have a string and i just concat a hex number to it. I just want to space out the numbers so that they will line up with the next string added, so that it has the look of a table. Right now i am padding the hex number like this:
int myString = 10005; int myString2 = 20003; testStr.Format("%03X" , myString); Str += testStr; testStr.Format("%03X" , myString2); Str += testStr; Listbox.AddString(Str);
I know if i take away the 0, then it will set the width, but i need to do both. CAN THIS BE DONE? thanks in advance. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
You could do it in two stages, format the hex value, then take that as further input to another Format call, using %8.8s (pad on right) or %-8.8s (pad on left) as the format string second time around eg testStr1.Format("%03X",myString); testStr2.Format("%03X",myString2); Str.Format("%10.10s%10.10s",testStr1,testStr2); Steve S I was 15 once. It was a long time ago. Today, it's 22 years since I started working full-time in IT.
-
You could do it in two stages, format the hex value, then take that as further input to another Format call, using %8.8s (pad on right) or %-8.8s (pad on left) as the format string second time around eg testStr1.Format("%03X",myString); testStr2.Format("%03X",myString2); Str.Format("%10.10s%10.10s",testStr1,testStr2); Steve S I was 15 once. It was a long time ago. Today, it's 22 years since I started working full-time in IT.