Margins.Left Özellik

Tanım

Sol kenar boşluğu genişliğini bir inçin yüzde biri cinsinden alır veya ayarlar.

C#
public int Left { get; set; }

Özellik Değeri

Sol kenar boşluğu genişliği, bir inçin yüzde biri.

Özel durumlar

Left özelliği 0'dan küçük bir değere ayarlanır.

Örnekler

System.DrawingBu örnek için , System.Drawing.Printingve System.IO ad alanlarını kullanın.

Aşağıdaki kod örneği, belgenin varsayılan sayfa ayarlarını 1 inç genişlikte sol ve sağ kenar boşluklarına, üst ve alt kenar boşlukları ise 1,5 inç genişliğe ayarlar.

C#
public void Printing()
{
  try 
  {
    /* This assumes that a variable of type string, named filePath,
       has been set to the path of the file to print. */
    streamToPrint = new StreamReader (filePath);
    try 
    {
      printFont = new Font("Arial", 10);
      PrintDocument pd = new PrintDocument(); 
      /* This assumes that a method, named pd_PrintPage, has been
         defined. pd_PrintPage handles the PrintPage event. */
      pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
      /* This assumes that a variable of type string, named 
         printer, has been set to the printer's name. */
      pd.PrinterSettings.PrinterName = printer;

      // Set the left and right margins to 1 inch.
      pd.DefaultPageSettings.Margins.Left = 100;
      pd.DefaultPageSettings.Margins.Right = 100;
      // Set the top and bottom margins to 1.5 inches.
      pd.DefaultPageSettings.Margins.Top = 150;
      pd.DefaultPageSettings.Margins.Bottom = 150;

      pd.Print();
    } 
    finally 
    {
      streamToPrint.Close() ;
    }
  } 
  catch(Exception ex) 
  { 
    MessageBox.Show("An error occurred printing the file - " + ex.Message);
  }
}

Açıklamalar

Kenar boşluklarını milimetre cinsinden ölçerseniz, milimetre cinsinden istediğiniz kenar boşluğu genişliğini 3,937 ile çarparak bir inçin yüzde biri cinsinden doğru ölçümü belirleyin. Örneğin, 25 mm kenar boşluğu istiyorsanız, 3,937 ile çarpın ve aşağı yuvarlandığında sonuç 98 olur. Ardından uygun Margins üyeyi 98 olarak ayarlayabilirsiniz.

Şunlara uygulanır

Ürün Sürümler
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Ayrıca bkz.