0

i am drawing my listview before i print it and i can align columns to the right with StringAlignment.Far but it draws all column to the right, can i draw my first description column to the left and price column to the right?

           if (Controls[i].GetType() == this.listView1.GetType())
            {
                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Far;
                for (int row = 0; row < listView1.Items.Count; row++)
                {
                    int nextColumnPosition = listView1.Bounds.X;
                    for (int col = 0; col < listView1.Items[row].SubItems.Count; col++)
                    {
                        g.DrawString(listView1.Items[row].SubItems[col].Text, listView1.Items[row].Font, Brushes.Black, (nextColumnPosition + 3) * scalex, (listView1.Items[row].Bounds.Y + listView1.Bounds.Y) * scaley, stringFormat);
                        nextColumnPosition += listView1.Columns[col].Width;

                    }
                }
            }  
marda
  • 1
  • Try stretching the description column. Btw the condition at the first line seems to be redundant. – rocky Apr 02 '13 at 07:33
  • maybe i need to add a if clause { if description column HorizontalAlignment.Left than stringFormat.Alignment = StringAlignment.Near; else stringFormat.Alignment = StringAlignment.Far; – marda Apr 02 '13 at 08:29

0 Answers0