 |
|
จากคำสั่งนี้ผมจะใส่สีพื้นหลัง (ฺBackColor) และจะกึ่งกลาง (Center) ยังไงครับ |
|
 |
|
|
 |
 |
|
Code
Dim text1 As String = "Draw text in a rectangle by passing a RectF to the DrawString method."
Dim font1 As New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
Try
Dim rectF1 As New RectangleF(30, 10, 100, 122)
e.Graphics.DrawString(text1, font1, Brushes.Blue, rectF1)
e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(rectF1))
Finally
font1.Dispose()
End Try
ถ้าผมต้องการจะเพิ่มสีพื้นหลัง และจัดตัวอักษรให้อยู่กึ่งกลาง (ไม่รู้ว่าต้องใช้คำสั่งอะไร)
Tag : .NET, VB.NET
|
|
 |
 |
 |
 |
Date :
2014-11-25 20:40:59 |
By :
gungsakab |
View :
1330 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอภาพ ณ ปัจจุบันด้วยครับ
|
 |
 |
 |
 |
Date :
2014-11-26 09:29:51 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

Code (C#)
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Bitmap buffer = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
using (Graphics graphics = Graphics.FromImage(buffer))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.FillRectangle(new SolidBrush(Color.FromArgb(0x40, 0, 0xff, 0)), 10, 10, 500, 80);
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
TextRenderer.DrawText(graphics, "Hello World By TOR@Chemistry", this.Font,new Point(170,50), Color.Black);
}
e.Graphics.DrawImageUnscaled(buffer, this.ClientRectangle);
}
}
ประมาณนี้ป่ะครับ(ว่าแต่ทำไมไม่ใช้ label รึครับ)
|
 |
 |
 |
 |
Date :
2014-11-26 09:35:34 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโทษทีครับ ลืมเข้ามาบอก ไปอ่าน HELP แล้ว ทำได้แล้วครับ
ยังไงก็ขอบคุณทั้ง 2 ท่านนะครับ ที่เข้ามาช่วยเหลือ

|
 |
 |
 |
 |
Date :
2014-11-26 14:45:02 |
By :
gungsakab |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอาแชร์กันด้วยก็ดีครับ
|
 |
 |
 |
 |
Date :
2014-11-26 14:57:29 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้เลยครับ..ไม่ได้เข้ามาดูเลย ต้องขอโทษด้วยครับ
พรุ่งนี้ บ่ายๆ จะเอามาร่วมแชร์นะครับ
ตอนนี้ขอตัวไปตั้งคำถามก่อน ^^
|
 |
 |
 |
 |
Date :
2015-01-19 20:11:18 |
By :
gungsakab |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
code ประมาณนี้ครับ
Code
Dim stringFormat As New StringFormat
stringFormat.Alignment = StringAlignment.Center
stringFormat.LineAlignment = StringAlignment.Center
Dim stringOPayment As New StringFormat
stringOPayment.Alignment = StringAlignment.Center
stringOPayment.LineAlignment = StringAlignment.Center
Dim LBOPayment As New RectangleF(30, 188, 24, 24)
Dim BCBrush8 As New SolidBrush(Color.Red)
Dim rect8 As New Rectangle(30, 188, 24, 24)
e.Graphics.FillRectangle(BCBrush8, rect8)
e.Graphics.DrawString(Label8.Text, fontOPayment, Brushes.Black, LBOPayment, stringOPayment)
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(LBOPayment))
|
 |
 |
 |
 |
Date :
2015-01-22 14:24:39 |
By :
gungsakab |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|