本文整理匯總了C#中System.Drawing.StringFormat.GetTabStops方法的典型用法代碼示例。如果您正苦於以下問題:C# StringFormat.GetTabStops方法的具體用法?C# StringFormat.GetTabStops怎麽用?C# StringFormat.GetTabStops使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.StringFormat
的用法示例。
在下文中一共展示了StringFormat.GetTabStops方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetSetTabStopsExample1
public void GetSetTabStopsExample1(PaintEventArgs e)
{
Graphics g = e.Graphics;
// Tools used for drawing, painting.
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0));
SolidBrush blueBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255));
// Layout and format for text.
Font myFont = new Font("Times New Roman", 12);
StringFormat myStringFormat = new StringFormat();
Rectangle enclosingRectangle = new Rectangle(20, 20, 500, 100);
float[] tabStops = {150.0f, 100.0f, 100.0f};
// Text with tabbed columns.
string myString =
"Name\tTab 1\tTab 2\tTab 3\nGeorge Brown\tOne\tTwo\tThree";
// Set the tab stops, paint the text specified by myString, and draw the
// rectangle that encloses the text.
myStringFormat.SetTabStops(0.0f, tabStops);
g.DrawString(myString, myFont, blueBrush,
enclosingRectangle, myStringFormat);
g.DrawRectangle(redPen, enclosingRectangle);
// Get the tab stops.
float firstTabOffset;
float[] tabStopsObtained = myStringFormat.GetTabStops(out firstTabOffset);
for(int j = 0; j < tabStopsObtained.Length; j++)
{
// Inspect or use the value in tabStopsObtained[j].
Console.WriteLine("\n Tab stop {0} = {1}", j, tabStopsObtained[j]);
}
}