Usuário com melhor resposta
Textbox com align a direita no print VB

Pergunta
-
Eu tenho um printdocument com o seguinte comando
Dim font1 As New Font("Arial", 15, FontStyle.Regular) e.Graphics.DrawString(txtnome.Text, font1, Brushes.Black, 10, 10)
E quando eu imprimo o textbox fica da esquerda pra direita, mesmo com a propriedade do textbox com textalign: right.
Como faço para que na impressão fique igual no textbox com o texto vindo da direita pra esquerda?
- Editado Mateus Justino quinta-feira, 12 de abril de 2018 12:42
Respostas
-
Boa tarde.
Você deve informar alinhamento, conforme exemplo abaixo.
Veja neste link.
https://msdn.microsoft.com/pt-br/library/21kdfbzs(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
Public Sub DrawStringRectangleFFormat(ByVal e As PaintEventArgs) ' Create string to draw. Dim drawString As [String] = "Sample Text" ' Create font and brush. Dim drawFont As New Font("Arial", 16) Dim drawBrush As New SolidBrush(Color.Black) ' Create rectangle for drawing. Dim x As Single = 150.0F Dim y As Single = 150.0F Dim width As Single = 200.0F Dim height As Single = 50.0F Dim drawRect As New RectangleF(x, y, width, height) ' Draw rectangle to screen. Dim blackPen As New Pen(Color.Black) e.Graphics.DrawRectangle(blackPen, x, y, width, height) ' Set format of string. Dim drawFormat As New StringFormat drawFormat.Alignment = StringAlignment.Center ' Draw string to screen. e.Graphics.DrawString(drawString, drawFont, drawBrush, _ drawRect, drawFormat) End Sub
MARIANO1776
- Marcado como Resposta Filipe B CastroModerator quarta-feira, 2 de maio de 2018 21:38
Todas as Respostas
-
Boa tarde.
Você deve informar alinhamento, conforme exemplo abaixo.
Veja neste link.
https://msdn.microsoft.com/pt-br/library/21kdfbzs(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
Public Sub DrawStringRectangleFFormat(ByVal e As PaintEventArgs) ' Create string to draw. Dim drawString As [String] = "Sample Text" ' Create font and brush. Dim drawFont As New Font("Arial", 16) Dim drawBrush As New SolidBrush(Color.Black) ' Create rectangle for drawing. Dim x As Single = 150.0F Dim y As Single = 150.0F Dim width As Single = 200.0F Dim height As Single = 50.0F Dim drawRect As New RectangleF(x, y, width, height) ' Draw rectangle to screen. Dim blackPen As New Pen(Color.Black) e.Graphics.DrawRectangle(blackPen, x, y, width, height) ' Set format of string. Dim drawFormat As New StringFormat drawFormat.Alignment = StringAlignment.Center ' Draw string to screen. e.Graphics.DrawString(drawString, drawFont, drawBrush, _ drawRect, drawFormat) End Sub
MARIANO1776
- Marcado como Resposta Filipe B CastroModerator quarta-feira, 2 de maio de 2018 21:38
-
Boa tarde,
Por falta de retorno essa thread está encerrada.
Se necessário, favor abrir uma nova thread.
Atenciosamente,Filipe B de Castro
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.