barriers / 阅读 / 详情

c# picturebox控件显示文字问题

2023-08-01 17:58:37
共2条回复
北境漫步

原因是:画面刷新的时候,把你的字给覆盖了

解决方法:

创建一个Bitmap

在Bitmap上面绘制文字

再把pb的BackGroundImage属性设置为这个Bitmap对象

康康map

第一个问题,你的背景色盖了绘制的文字

第二个问题,this.pictureBox1.TabIndex = 0;this.pb.TabIndex=1;

相关推荐

drawstring是什么意思

drawstring 英[u02c8dru0254:stru026au014b] 美[u02c8dru0254u02ccstru026au014b] n. (穿在口袋或裤腰的)拉带,细绳
2023-08-01 12:11:423

JAVA中,drawstring 方法的用法,格式是什么啊

分类: 电脑/网络 >> 程序设计 >> 其他编程语言 问题描述: drawstring 方法的用法,格式是什么啊 解析: drawString public abstract void drawString(String str, int x,int y) 使用此图形上下文的当前字体和颜色绘制由指定 string 给定的文本。最左侧字符的基线位于此图形上下文坐标系统的 (x, y) 位置处。 参数: str - 要绘制的 string。 x - x 坐标。 y - y 坐标。 另请参见: drawBytes(byte[], int, int, int, int), drawChars(char[], int, int, int, int) -------------------------------------------------------------------------------- drawString public abstract void drawString(AttributedCharacterIterator iterator, int x, int y) 使用此图形上下文的当前颜色绘制由指定迭代器给定的文本。迭代器必须为每个字符指定字体。最左侧字符的基线位于此图形上下文坐标系统的 (x, y) 位置处。 参数: iterator - 要绘制其文本的迭代器 x - x 坐标。 y - y 坐标。 另请参见: drawBytes(byte[], int, int, int, int), drawChars(char[], int, int, int, int)
2023-08-01 12:12:111

JAVA中,drawstring 方法的用法,格式是什么?

int y)使用此图形上下文的当前字体和颜色绘制由指定 string 给定的文本。最左侧字符的基线位于此图形上下文坐标系统的 (x, y) 位置处。 参数:str - 要绘制的 string。 x - x 坐标。 y - y 坐标。 另请参见:drawBytes(byte[], int, int, int, int), drawChars(char[], int, int, int, int) --------------------------------------------------------------------------------drawStringpublic abstract void drawString(AttributedCharacterIterator iterator, int x, int y)使用此图形上下文的当前颜色绘制由指定迭代器给定的文本。迭代器必须为每个字符指定字体。最左侧字符的基线位于此图形上下文坐标系统的 (x, y) 位置处。 参数:iterator - 要绘制其文本的迭代器 x - x 坐标。 另请参见:drawBytes(byte[], int, int, int, int), drawChars(char[], int, int, int, int)参考资料:javadoc
2023-08-01 12:12:181

求教java中的drawString步骤

在一个JPanel、或JLabel等界面组件,覆盖 paint(Graphics)就可以使用Graphics的drawString方法了~~~
2023-08-01 12:12:262

c# DrawString 如果让 文本从右到左的输出?

你按换行切割一下原字符,变成字符串数组,再逆序每一行,逐行DrawString
2023-08-01 12:12:353

vb6怎么实现DRAWSTRING功能,只有15分了...

DRAWSTRING功能,是个什么功能,最好描述一下。
2023-08-01 12:12:433

c#动态使用DrawString

使用TIMER控件,设置固定时间间隔(1秒)响应事件。在事件函数中控制坐标值随着时间的变化而变化,然后再调用DrawString方法。至于让前面出现的字符串消失,再写个方法控制,这应该也不难办到的。定义一个Graphics类,用它调用DrawString方法,例如:Graphics g=Graphics.FromImage(map);map就是你要在上面画串的位图。加行g.dispose();呢
2023-08-01 12:12:501

C#中使用DrawString绘制文本时怎样使文本居中或右对齐

format.LineAlignment = StringAlignment.Center; // 更正: 垂直居中format.Alignment = StringAlignment.Center; // 水平居中RectangleF 排版框 = new Rectangle(Point.Zero, new Size(nWidth, nHeight));g.DrawString(_ShowName, stringFont, Brushes.Black, 排版框, format);
2023-08-01 12:13:081

java绘图方法drawString如何改变字体

先用这个方法public abstract void setColor(Color c)将当前字体改变成你想要的字体然后drawString就可以了·
2023-08-01 12:13:162

g.drawString如何换行输出?

建议自己切割字符串,然后循环用drawstring吧java确实没自动换行的功能
2023-08-01 12:13:232

急救!Graphics 中的方法 drawString(String, int, int)对于参数(String, double)不适用 什么意思啊?

drawString()的参数应该是(String, int, int) 也就是字符串和两个整数,两个整数分别是字符串图形左上角那点的横纵坐标.而你给的值是D(0.0)和10.50这两个double类型的,所以类型不合.换成int类的就可以了.
2023-08-01 12:13:301

用java画板drawString的字,可以改变大小吗

可以,用Graphics类的void setFont(Font font)方法来,设定字体的名称,大小,是否加粗斜体等.例如 Font f=new Font(null,Font.PLAIN,20);用这个语句定义一个缺省字体名称大小20磅的普通字体对象f,然后用g.setFont(f);为图形对象Graphics g设定字体大小,画板drawString的字体大小就会改变了.
2023-08-01 12:13:391

.net里用drawstring时,指定显示的宽度后,怎么计算文本块的高度?

这个主要是计算字符串的高度,就是字符串设定字体、尺寸后,计算其所占的像素范围。计算方法的网址我已经私信发给你了。请检查。
2023-08-01 12:13:471

如何在drawString绘出的文字上加入背景颜色

你在绘制字符串之前可以使用Graphics的MeasureString方法测量它的尺寸再绘制一个相应大小的矩形就行了,如下Graphics g = this.CreateGraphics();Font font = new Font("宋体", 9f);PointF pointF = new PointF(10, 10);SizeF sizeF = g.MeasureString("Hello World!", font);g.FillRectangle(Brushes.White, new RectangleF(pointF, sizeF));g.DrawString("Hello World!", font, Brushes.Black, pointF);g.Dispose();font.Dispose();
2023-08-01 12:13:541

C# DrawString函数,怎么有效限制绘制文字的宽度?

Graphics 对象有 SetClip(Rectangle) 和 ResetClip() 两个方法,可以先通过前者指定一个有效绘图区域,绘制后再重置有效区域。比如该 Graphics 的实际是 (0, 0, 200, 200),指定一个 (50, 50, 100, 100) 的矩形作为有效区域,那么超出该范围的部分不会被绘制在 Graphics 上。
2023-08-01 12:14:011

g.drawString什么意识??

把一段字符串 画在指定地方
2023-08-01 12:14:092

Graphics中drawString方法的y坐标表示的是字体左上角还是左下角

  DrawString(String, Font, Brush, PointF)  在指定位置并且用指定的 Brush 和 Font 对象绘制指定的文本字符串。  DrawString(String, Font, Brush, RectangleF)  在指定矩形并且用指定的 Brush 和 Font 对象绘制指定的文本字符串。  DrawString(String, Font, Brush, PointF, StringFormat)  使用指定 StringFormat 的格式化特性,用指定的 Brush 和 Font 对象在指定的位置绘制指定的文本字符串。
2023-08-01 12:14:161

如何控制drawstring时的字符间距?如何旋转字体

下面的代码显示围绕一点旋转的文字 for (float angle = 0; angle < 360; angle += 45) { g.ResetTransform(); g.TranslateTransform(rect.Width / 2, rect.Height / 2); g.RotateTransform(angle); g.DrawString("我的测试绘图", font, brush
2023-08-01 12:14:341

java graphis 的drawstring 方法怎么改变字体

用setFont()方法修改字体setFontpublic abstract void setFont(Font font)将此图形上下文的字体设置为指定字体。使用此图形上下文的所有后续文本操作均使用此字体。 参数:font - 字体。比如Graphics g = panel.getGraphics();g.setFont(new Font("Tahoma", Font.BOLD, 12));g.drawString("wahahahaha");
2023-08-01 12:14:421

DrawString如何对字符的行高和字符间距进行

下面的代码显示围绕一点旋转的文字for (float angle = 0; angle < 360; angle += 45){g.ResetTransform();g.TranslateTransform(rect.Width / 2, rect.Height / 2);g.RotateTransform(angle);g.DrawString("我的测试绘图", font, brush, 50, 0);}
2023-08-01 12:14:491

Java中c.getGraphics().drawString()是什么意思?

你的那个c是什么?我也不管你的c是什么了,这句的意思就是得到画布,然后在上面画字符串
2023-08-01 12:15:283

java入门问题,用了drawString却不显示字串

class PanelTest extends JPanel{ public void //PaintComponent(Graphics g)//这里写错了应该是小写的p { super.paintComponent(g); g.drawString("Hello Java", 75, 100); }}
2023-08-01 12:15:362

j2me中g.drawstring()求解

请参考 http://zhidao.baidu.com/question/314832678不想重复打字
2023-08-01 12:15:442

e.Graphics.DrawString 自定义颜色

System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(color); e.Graphics.DrawString("上海线", new Font(new FontFamily("黑体"), 170),brush, 240,350);
2023-08-01 12:15:511

C# e.Graphics.DrawString 垂直显示字符串

用FOR循环显示,将显示的字设定好坐标就行了
2023-08-01 12:16:103

asp.net C#中使用DrawString绘制文本时怎样使文本居中或右对齐

你的代码看著很累自己算下起点,用 图片宽度-“文字长度” 作为X座标的起点,用 (图片高度-“文字长度”)/2 作为X座标的起点,,不要用下面的 new PointF(0, 0),g.DrawString(_ShowName, stringFont, new SolidBrush(Color.Black), new PointF(0, 0), format);
2023-08-01 12:16:171

c#中e.Graphics.DrawString

换成这行代码试试:e.DrawString("你好",new Font("宋体",9.5f),new SolidBrush(Color.Black),rect)
2023-08-01 12:16:471

vb.net DrawString 座标单位是什么

单位是像素,跟控件的位置(location)的类型是一样的,控件的location就是它左上角的位置,同理,drawstring的坐标 ,即表示要绘制的第一个字的左上角的位置
2023-08-01 12:16:541

C# DrawString 斜显示

g.DrawString("天河公园", new Font("宋体",15,FontStyle.Italic), Brushes.Green, 10, 40);g是Graphics画板对象FontStyle.Italic倾斜
2023-08-01 12:17:012

vb.net中使Graphics.DrawString画一字符串都是横着显示,如何让此串字符竖着显示?

gf.DrawString("竖着的值", Font, Brush, new point(X,Y) ,new StringFormat(StringFormatFlags.DirectionVertical));用这个方法可以
2023-08-01 12:17:081

c#GUI的drawstring 怎么删除。。

用背景色填充
2023-08-01 12:17:162

Graphics DrawString 画出字体怎么不一样大啊?

可能是因为你是画在Image对象上的,而你的Image对象应用到控件是使用了拉伸选项。
2023-08-01 12:17:242

C#中使用DrawString绘制文本时怎样使文本居中或右对齐

format.LineAlignment = StringAlignment.Center; // 更正: 垂直居中format.Alignment = StringAlignment.Center; // 水平居中RectangleF 排版框 = new Rectangle(Point.Zero, new Size(nWidth, nHeight));g.DrawString(_ShowName, stringFont, Brushes.Black, 排版框, format);
2023-08-01 12:17:421

g.drawString(str,35,18)

可以多写点东西吗内容这么少,不太好判断 啊
2023-08-01 12:17:502

java绘图方法drawString如何改变字体

用setFont()方法修改字体setFontpublicabstractvoidsetFont(Fontfont)将此图形上下文的字体设置为指定字体。使用此图形上下文的所有后续文本操作均使用此字体。参数:font-字体。比如Graphicsg=panel.getGraphics();g.setFont(newFont("Tahoma",Font.BOLD,12));g.drawString("wahahahaha");
2023-08-01 12:18:041

Graphics.DrawString所输出的字符串 有办法自动换行吗

相关代码如下: /// <summary> /// 绘制文本自动换行(超出截断) /// </summary> /// <param name="graphic">绘图图面</param> /// <param name="font">字体</param> /// <param name="text">文本</param> /// <param name="recangle">绘制范围</param> private void DrawStringWrap(Graphics graphic, Font font, string text, Rectangle recangle) { List<string> textRows = GetStringRows(graphic, font, text, recangle.Width); int rowHeight = (int)(Math.Ceiling(graphic.MeasureString("测试", font).Height)); int maxRowCount = recangle.Height / rowHeight; int drawRowCount = (maxRowCount < textRows.Count) ? maxRowCount : textRows.Count; int top = (recangle.Height - rowHeight * drawRowCount) / 2; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Center; for (int i = 0; i < drawRowCount; i++) { Rectangle fontRectanle = new Rectangle(recangle.Left, top + rowHeight * i, recangle.Width, rowHeight); graphic.DrawString(textRows, font, new SolidBrush(Color.Black), fontRectanle, sf); } } /// <summary> /// 将文本分行 /// </summary> /// <param name="graphic">绘图图面</param> /// <param name="font">字体</param> /// <param name="text">文本</param> /// <param name="width">行宽</param> /// <returns></returns> private List<string> GetStringRows(Graphics graphic, Font font, string text, int width) { int RowBeginIndex = 0; int rowEndIndex = 0; int textLength = text.Length; List<string> textRows = new List<string>(); for (int index = 0; index < textLength; index++) { rowEndIndex = index; if (index == textLength - 1) { textRows.Add(text.Substring(RowBeginIndex)); } else if (rowEndIndex + 1 < text.Length && text.Substring(rowEndIndex, 2) == "\r\n") { textRows.Add(text.Substring(RowBeginIndex, rowEndIndex - RowBeginIndex)); rowEndIndex=index += 2; RowBeginIndex = rowEndIndex; } else if (graphic.MeasureString(text.Substring(RowBeginIndex, rowEndIndex - RowBeginIndex + 1), font).Width > width) { textRows.Add(text.Substring(RowBeginIndex, rowEndIndex - RowBeginIndex)); RowBeginIndex = rowEndIndex; } } return textRows; }
2023-08-01 12:18:111

用java画板drawString的字,可以改变大小吗

可以,用Graphics类的void setFont(Font font)方法来,设定字体的名称,大小,是否加粗斜体等.例如 Font f=new Font(null,Font.PLAIN,20);用这个语句定义一个缺省字体名称大小20磅的普通字体对象f,然后用g.setFont(f);为图形对象Graphics g设定字体大小,画板drawString的字体大小就会改变了.
2023-08-01 12:18:181

C#中使用DrawString绘制文本时怎样使文本居中或右对齐

format.LineAlignment = StringAlignment.Center; // 更正: 垂直居中format.Alignment = StringAlignment.Center; // 水平居中RectangleF 排版框 = new Rectangle(Point.Zero, new Size(nWidth, nHeight));g.DrawString(_ShowName, stringFont, Brushes.Black, 排版框, format);
2023-08-01 12:18:261

java中Graphics类drawString()方法问题

  DrawString(String, Font, Brush, PointF)  在指定位置并且用指定的 Brush 和 Font 对象绘制指定的文本字符串。  DrawString(String, Font, Brush, RectangleF)  在指定矩形并且用指定的 Brush 和 Font 对象绘制指定的文本字符串。  DrawString(String, Font, Brush, PointF, StringFormat)  使用指定 StringFormat 的格式化特性,用指定的 Brush 和 Font 对象在指定的位置绘制指定的文本字符串。  DrawString(String, Font, Brush, RectangleF, StringFormat)  使用指定 StringFormat 的格式化特性,用指定的 Brush 和 Font 对象在指定的矩形绘制指定的文本字符串。  DrawString(String, Font, Brush, Single, Single)  在指定位置并且用指定的 Brush 和 Font 对象绘制指定的文本字符串。  DrawString(String, Font, Brush, Single, Single, StringFormat)  使用指定 StringFormat 的格式化特性,用指定的 Brush 和 Font 对象在指定的位置绘制指定的文本字符串。
2023-08-01 12:18:332

Graphics.DrawString所输出的字符串 有办法自动换行吗

相关代码如下: /// <summary> /// 绘制文本自动换行(超出截断) /// </summary> /// <param name="graphic">绘图图面</param> /// <param name="font">字体</param> /// <param name="text">文本</param> /// <param name="recangle">绘制范围</param> private void DrawStringWrap(Graphics graphic, Font font, string text, Rectangle recangle) { List<string> textRows = GetStringRows(graphic, font, text, recangle.Width); int rowHeight = (int)(Math.Ceiling(graphic.MeasureString("测试", font).Height)); int maxRowCount = recangle.Height / rowHeight; int drawRowCount = (maxRowCount < textRows.Count) ? maxRowCount : textRows.Count; int top = (recangle.Height - rowHeight * drawRowCount) / 2; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Center; for (int i = 0; i < drawRowCount; i++) { Rectangle fontRectanle = new Rectangle(recangle.Left, top + rowHeight * i, recangle.Width, rowHeight); graphic.DrawString(textRows, font, new SolidBrush(Color.Black), fontRectanle, sf); } } /// <summary> /// 将文本分行 /// </summary> /// <param name="graphic">绘图图面</param> /// <param name="font">字体</param> /// <param name="text">文本</param> /// <param name="width">行宽</param> /// <returns></returns> private List<string> GetStringRows(Graphics graphic, Font font, string text, int width) { int RowBeginIndex = 0; int rowEndIndex = 0; int textLength = text.Length; List<string> textRows = new List<string>(); for (int index = 0; index < textLength; index++) { rowEndIndex = index; if (index == textLength - 1) { textRows.Add(text.Substring(RowBeginIndex)); } else if (rowEndIndex + 1 < text.Length && text.Substring(rowEndIndex, 2) == "\r\n") { textRows.Add(text.Substring(RowBeginIndex, rowEndIndex - RowBeginIndex)); rowEndIndex=index += 2; RowBeginIndex = rowEndIndex; } else if (graphic.MeasureString(text.Substring(RowBeginIndex, rowEndIndex - RowBeginIndex + 1), font).Width > width) { textRows.Add(text.Substring(RowBeginIndex, rowEndIndex - RowBeginIndex)); RowBeginIndex = rowEndIndex; } } return textRows; }
2023-08-01 12:18:412

Graphics.DrawString所输出的字符串 有办法自动换行吗

相关代码如下:/// <summary>/// 绘制文本自动换行(超出截断)/// </summary>/// <param name="graphic">绘图图面</param>/// <param name="font">字体</param>/// <param name="text">文本</param>/// <param name="recangle">绘制范围</param>private void DrawStringWrap(Graphics graphic, Font font, string text, Rectangle recangle){List<string> textRows = GetStringRows(graphic, font, text, recangle.Width);int rowHeight = (int)(Math.Ceiling(graphic.MeasureString("测试", font).Height));int maxRowCount = recangle.Height / rowHeight;int drawRowCount = (maxRowCount < textRows.Count) ? maxRowCount : textRows.Count;int top = (recangle.Height - rowHeight * drawRowCount) / 2;StringFormat sf = new StringFormat();sf.Alignment = StringAlignment.Near;sf.LineAlignment = StringAlignment.Center;for (int i = 0; i < drawRowCount; i++){Rectangle fontRectanle = new Rectangle(recangle.Left, top + rowHeight * i, recangle.Width, rowHeight);graphic.DrawString(textRows, font, new SolidBrush(Color.Black), fontRectanle, sf);}}
2023-08-01 12:18:481

C#DrawString 怎么设置字间距和行间距

下面的代码显示围绕一点旋转的文字 for (float angle = 0; angle < 360; angle += 45) { g.ResetTransform(); g.TranslateTransform(rect.Width /
2023-08-01 12:19:061

c#用drawstring画图,怎么消除锯齿?

画之前加上这句。g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
2023-08-01 12:19:131

C# Graphics.DrawString加背景色

文字的长度不知道,可以让它是个变量,变量.Length 就可以知道长度了。然后再把要写文字的部分填充了。最后在DrawString();
2023-08-01 12:19:212

vb中使用graphics.drawstring画字符串窗体只能显示一部分,怎么设置显示全部

这是vb.net题,跟vb不太一样
2023-08-01 12:19:281

c# g.drawstring()如何让文字向下倾斜45度?

旋转的时候要选一个中心点吧。默认应该是左上角咯。所以旋转后就跑屏幕外面了。
2023-08-01 12:19:362

C# 通过Graphics.DrawString在图片上写文字为什么会有阴影呢?

Bitmap img = new Bitmap(100, 50);Graphics graphics = Graphics.FromImage(img); graphics.Clear(Color.White)
2023-08-01 12:19:511

使用java.awt.Graphics中的drawString方法如何让文字换行?

楼主,换行要自己换行的,可以根据Font测量字符占用的点数,然后判断是否该换行
2023-08-01 12:19:581

GDI+中用DrawString()在制定RectF范围内绘制字符串,如何实现它不额外绘制一个空白区域

那你要计算你画的字符串的长度和宽度,且需根据字体、型号大小、字体样式(居中还是靠左)。这些来完成。且还要注意有无换行符号 和 。以下是GDI代码,供你参考。void CalculateTextSize() { if ( m_bAutoCalText && ::IsWindow(m_hWnd) ) { // Calculate text size. CClientDC dc(m_hWnd); dc.SelectFont(m_Font); dc.SetTextAlign(m_uTextStyle); CSize szText; CString strText =_T(""); int nHeight = 0; int nWidth = 0; // Get max text length and width. for (int i = 0; i < m_strText.GetLength(); i++) { strText += m_strText[i]; if (m_strText[i] == " " ||m_strText[i] == " ") { dc.GetTextExtent(strText,strText.GetLength(), &szText); nHeight += szText.cy; nWidth = nWidth > szText.cx ? nWidth :szText.cx; strText = _T(""); } } if (strText.GetLength() > 0) { dc.GetTextExtent(strText,strText.GetLength(), &szText); nHeight += szText.cy; nWidth = nWidth > szText.cx ?nWidth : szText.cx; strText = _T(""); } ResizeClient(nWidth, nHeight); } Invalidate(); }
2023-08-01 12:20:051

用eclipse写的。用了JPanel类的drawString编译后却显示不出来相应的内容

public void paintComonent(Graphics g) { Graphics2D g2 = (Graphics2D)g; //添加这一句g2.drawString("hello",75,75); //这里用g2调用}
2023-08-01 12:20:132