上の応用。
private void detail_Format(object sender, EventArgs e)
{
txt2ndText.Location = GetTextEndLocation(txt1stText);
}
private PointF GetTextEndLocation(TextBox oTextBox)
{
// 文字の大きさを取得
Page oMeasurePage = new Page(); // 作業用のページオブジェクト
oMeasurePage.Font = oTextBox.Font;
SizeF oTextSize = oMeasurePage.MeasureText(oTextBox.Text);
// 文字の最後の位置を取得
PointF oTextEndLocation = oTextBox.Location;
oTextEndLocation.X += oTextSize.Width;
return oTextEndLocation;
}