|  |  | 
          
            | Code (C#) 
             Graphics graphic = e.Graphics;
            Font font = new Font("Angsana New", 12);
            float fontHeight = font.GetHeight();
            int startX = 10;
            int startY = 10;
            int offset = 135;
            graphic.DrawString("                  ร้านวัฒนวณิชย์", new Font("Angsana New", 17), new SolidBrush(Color.Black), startX, startY);
            graphic.DrawString("           110 หมู่ที่ 1 ต.บ้านแพ้ว อ.บ้านแพ้ว", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY + 30);
            graphic.DrawString("              จังหวัด สมุทรสาคร 74120", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY + 50);
            graphic.DrawString("                Tel.034-481-253", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY+70);
            graphic.DrawString("          สินค้า                                 จำนวน      ราคา", new Font("Angsana New", 12), new SolidBrush(Color.Black), startX, startY+110);
            graphic.DrawString("----------------------------------------------------", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY+120);
            while (sqlite_datareader.Read())
            {
                string product = (sqlite_datareader.GetString(4) + " " + sqlite_datareader.GetString(5) + " (" + sqlite_datareader.GetString(6)+")").PadRight(40);
                int princ = sqlite_datareader.GetInt32(14);
                string productLine = product+ "1         " + String.Format("{0:c}", princ);
                graphic.DrawString(productLine, font, new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + (int)fontHeight + 5;
            }
            offset = offset + 15;
            graphic.DrawString("                       ราคารวม  " + totalprice + "  บาท", new Font("Angsana New", 14), new SolidBrush(Color.Black), startX, startY + offset);
        }
 ด้านบนเป็น Code ของผมที่ต้องการสร้างฟอร์มเอกสารใบเสร็จขึ้นมาครับ โดยตัวลายละเอียดสินค้านั้น จะให้โชว์ ชื่อสินค้า จำนวน และก็ราคา โดยที่เว้นระยะห่างเท่าๆกันครับ เลยใช้คำสั่ง PadRight(40) ลงไป แต่ก็ออกมาดั่งที่เห็น
 
 
  
 ผมพลาดตรงไหนไปรึเปล่าครับ รบกวนแนะนำด้วยครับ
 
 ขอบคุณครับ
 
 
 
 Tag : Report Others, Win (Windows App), C#, Windows
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2018-09-17 18:14:45 | By :
                          zlzca71013 | View :
                          1024 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |