I'm trying to make the prices of the products in a textarea to be a straight line. However, as the length of the product names is different, it would require different amounts of "\t" to get the prices to be vertically aligned.
Here's a sample of what I'm trying to do:
string text = "1X " + "ABC Brand Drink \t\t\t\t " + price + "\n" + "2X" +
"BCD Drink that has a longer name \t\t" + price;
My question is, is there a way to make my prices vertically aligned without using all the "\t" escape sequences? I wouldn't know how many "\t" to use the text will be programmatically generated, so I wouldn't know how to gauge the #.
Here's a sample output that I'm working towards: https://i.stack.imgur.com/KvUQx.jpg
I am trying to use this in the HelloSign API template's to populate the custom text field.
UPDATE: So far I used the String.PadRight property as suggested in the comments, it kind of works but the price still isn't completely aligned. Here's a picture of what the current outcome is: https://i.stack.imgur.com/Twsvx.jpg. Here are the codes I used:
ArrayList al = new ArrayList();
string prodName = "Try out product A and product B2";
string price = "$620";
string quantity = "1X";
Product a = new Product(prodName, price, quantity);
al.Add(a);
string prodName2 = "Out product A and product Basdasddddddasd";
string price2 = "$650";
string quantity2 = "123X";
al.Add(new Product(prodName2, price2, quantity2));
string str = "";
string abs = "";
int nam, quan = 0;
int asdsd = 0;
foreach (Product p in al)
{
abs = "";
nam = p.ProdName.Length;
quan = p.ProdQuantity.Length;
abs += p.ProdQuantity + " " + p.ProdName;
//if ((nam + quan) % 2 == 0)
//{
// asdsd = (175 - (nam + quan));
//}
//else
//{
// asdsd = (175 - (nam + quan) - 1);
//}
asdsd = (175 - (nam + quan));
str += abs.PadRight(asdsd) + p.ProdPrice + "\n\n";
Please ignore the names of the variables, I will change them after everything is completed.