tailieunhanh - Professional Microsoft Smartphone Programming phần 9

Thông thường, trước khi gọi dây kéo () phương pháp, trước tiên bạn nên gọi Đồ họa:: MeasureString () để có được một cấu trúc RectangleF của hộp văn bản biên có thể được thông qua dây kéo (). Lý do cơ bản là khi một chuỗi trong một phông chữ được đo, thêm một số khoảng cách và treo lơ lửng glyphs sẽ được bổ sung vào kết quả. | Chapter 15 Normally before calling the DrawString method you should first call Graphics MeasureString to obtain a RectangleF structure of the bounding text box that can be passed to DrawString . The underlying reason is that when a string in a font is measured some extra spacing and overhanging glyphs will be added to the result. With this piece of information you can use the DrawString method to finely control the string display by placing the text at the appropriate location or adjusting the alignment. The following is an example of using the MeasureString method to obtain the size of the text Measure string size first SizeF szeText .NET Compact Framework rocks Font new Pen 0 0 int int .NET Compact Framework rocks Font new SolidBrush 0 0 To place your text string into a rectangular box you must pass a Rectangle object to DrawString RectangleF rct new RectangleF 30F 30F 200F 100F Smartphone Application rocks Font new SolidBrush rct If the rectangle is not wide enough to hold the string then the text will wrap around to the next line if there is sufficient space. If no space is available the text string will be truncated. The text is left-aligned and top-aligned by default. If you want to change the formatting use a StringFormat object and pass it to DrawString RectangleF rct new RectangleF 0 30F 200 60 StringFormat strFmt new StringFormat Text will be put at the bottom of the Rectangle Text will be put in the middle on a horizontal line Mobile Font new SolidBrush rct strFmt The StringFormat Alignment property determines how the text is aligned horizontally and the StringFormat LineAlignment property specifies the vertical position of the text in a rectangle. Both of these properties get the value from the StringAlignment enumeration where .

TÀI LIỆU MỚI ĐĂNG
8    170    0    20-04-2024
10    155    0    20-04-2024
20    197    2    20-04-2024
15    183    0    20-04-2024
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.