您现在的位置是: 首页 > 成语成因 成语成因
drawstring-Drawstring backpack
tamoadmin 2024-10-16 人已围观
简介下面的代码示例演示如何使用DrawString方法Graphics窗体上绘制文本。 或者,可以使用TextRenderer窗体上绘制文本。 有关详细信息,请参阅如何: 用 GDI 绘制文本。示例C#复制public void DrawString(){System.Drawing.Graphics formGraphics = this.CreateGraphics(); string dr
下面的代码示例演示如何使用DrawString方法Graphics窗体上绘制文本。 或者,可以使用TextRenderer窗体上绘制文本。 有关详细信息,请参阅如何: 用 GDI 绘制文本。
示例
C#复制
public void DrawString(){
System.Drawing.Graphics formGraphics = this.CreateGraphics(); string drawString = "Sample Text";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); float x = 150.0F; float y = 50.0F;
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose();
}
vb中使用graphics.drawstring画字符串窗体只能显示一部分,怎么设置显示全部
Graphics 对象有 SetClip(Rectangle) 和 ResetClip() 两个方法,可以先通过前者指定一个有效绘图区域,绘制后再重置有效区域。
比如该 Graphics 的实际是 (0, 0, 200, 200),指定一个 (50, 50, 100, 100) 的矩形作为有效区域,那么超出该范围的部分不会被绘制在 Graphics 上。
java入门问题,用了drawString却不显示字串
应该是绘画文字后,窗口重绘时清除了那一块区域。
所以放窗体的Paint事件里就行了。
Private?Sub?Form1_Paint(ByVal?sender?As?Object,?ByVal?e?As?System.Windows.Forms.PaintEventArgs)?Handles?Me.Paint'?在?Paint?事件参数中提供了?Graphics.?无需?Create.
Using?g?As?Graphics?=?e.Graphics
Dim?myfont?As?New?Font("微软雅黑",?50)
Dim?mybrush?As?New?SolidBrush(Color.Red)
g.DrawString("今天发工资啦!",?myfont,?mybrush,?10,?30)
End?Using
End?Sub
asp.net C#中使用DrawString绘制文本时怎样使文本居中或右对齐
因为 class PanelTest extends JPanel
{
public void PaintComponent(Graphics g)//方法名应该小写,才能重写。
{
super.paintComponent(g);
g.drawString("Hello Java", 75, 100);
}
所以,改为以下:class PanelTest extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("Hello Java", 75, 100);
}
就可以。
否则,不能重写该方法。
求救!VC6 中DrawString使用
你的代码看著很累
自己算下起点,用 宽度-“文字长度” 作为X座标的起点,
用 (高度-“文字长度”)/2 作为X座标的起点,
,不要用下面的 new PointF(0, 0),
g.DrawString(_ShowName, stringFont, new SolidBrush(Color.Black), new PointF(0, 0), format);
string 和 thread 的区别
graph.DrawString(((const WCHAR*)(LPCTSTR)strPrint,-1,&Font(L"黑体",17,FontStyleBold),Point(0,280),&SolidBrush(Color::Red));
这样可以吗?
java swing中Graphic的drawString方法在同一位置绘制变化的数字,前后的混在一起
thread有时会表示针线的线(用毛/棉做的线),而string没有这种用法。但是表示绳子的时候,几乎相同,但是thread会比较细长,而string只是质量轻,没有对细度和长度方面的暗示。
详见以下英文释义
名词string:
1. a lightweight cord
同义词:twine
2. stringed instruments that are played with a bow
同义词:bowed stringed instrument
3. a tightly stretched cord of wire or gut, which makes sound when plucked, struck, or bowed
4. a sequentially ordered set of things or events or ideas in which each successive member is related to the preceding
同义词:train
5. a linear sequence of symbols (characters or words or phrases)
6. a tie consisting of a cord that goes through a seam around an opening
同义词:drawstring, drawing string
7. (cosmology) a hypothetical one-dimensional subatomic particle having a concentration of energy and the dynamic properties of a flexible loop
同义词:cosmic string
8. a collection of objects threaded on a single strand
9. a necklace made by a stringing objects together;
同义词:chain, strand
名词thread:
1. a fine cord of twisted fibers (of cotton or silk or wool or nylon etc.) used in sewing and weaving
同义词:yarn
2. any long object resembling a thin line
同义词:ribbon
3. the connections that link the various parts of an event or argument together
同义词:train of thought
4. the raised helical rib going around a screw
同义词:screw thread
C#中使用DrawString绘制文本时怎样使文本居中或右对齐
楼上正解,之所以混在一起,是因为你没擦掉,0-0。擦掉的方法就同楼上所说,有两种:
1. super.paintComponent(g),会调用组件的原始界面重绘一次,这样你上次绘制上去的文本就不在了,也就相当于擦除了;
2. g.clearRect(x,y,w,h),这个就更直白了,就是擦除这个区域
format.LineAlignment = StringAlignment.Center; // 更正: 垂直居中
format.Alignment = StringAlignment.Center; // 水平居中
RectangleF 排版框 = new Rectangle(Point.Zero, new Size(nWidth, nHeight));
g.DrawString(_ShowName, stringFont, Brushes.Black, 排版框, format);
上一篇:姿组词语-姿组词语有哪些
下一篇:相冲不相克-相冲不可打一生肖