Faça sua doação e ajude-nos a manter o site
Visite nossa loja. E sempre que for comprar alguma coisa, compre por lá. Assim você ajuda a manter o site.
Obrigado pela sua colaboração.
Visitar Loja OnLine
Abaixo algumas sessões:
Até o momento, recebemos3948611 vizualizações de páginas (page views) desde 11/09/2004
Desenvolvedores.net: Fóruns
http://desenvolvedores.net :: Exibir tópico - TEXTBOX COM CANTOS ARREDONDADOS EM C#
Exibir mensagem anterior :: Exibir próxima mensagem
Autor
Mensagem
rrelvas Registrado em: Jul 06, 2010 Mensagens: 1
Enviada: Ter Jul 06, 2010 12:49 pm Assunto: TEXTBOX COM CANTOS ARREDONDADOS EM C#
Como criar textbox com cantos arredondados em C#?
Voltar ao Topo
Marcelo Administradores Registrado em: 1093441569 Mensagens: 773 Localização: SP
Enviada: Qua Jul 07, 2010 11:34 am Assunto:
O textBox nao tem esta opção, vc teria que criar o seu próprio textBox.
Uma idéia seria usar um RectangleShape e dentro dele colocar o textbox.
Abaixo eu fiz um user control como exemplo.
No seu projeto crie um novo "UserControl"
Apague o arquivo UserControl.Design.cs e cole este Código no UserControl.cs
Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyControls
{
public class MyTextBox : UserControl
{
public MyTextBox()
{
InitializeComponent();
}
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer1;
private Microsoft.VisualBasic.PowerPacks.RectangleShape rectangleShape1;
private TextBox textBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param>true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.shapeContainer1 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
this.rectangleShape1 = new Microsoft.VisualBasic.PowerPacks.RectangleShape();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// shapeContainer1
//
this.shapeContainer1.Location = new System.Drawing.Point(0, 0);
this.shapeContainer1.Margin = new System.Windows.Forms.Padding(0);
this.shapeContainer1.Name = "shapeContainer1";
this.shapeContainer1.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
this.rectangleShape1});
this.shapeContainer1.Size = new System.Drawing.Size(150, 55);
this.shapeContainer1.TabIndex = 0;
this.shapeContainer1.TabStop = false;
//
// rectangleShape1
//
this.rectangleShape1.BackColor = System.Drawing.Color.White;
this.rectangleShape1.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque;
this.rectangleShape1.CornerRadius = 4;
this.rectangleShape1.Location = new System.Drawing.Point(4, 3);
this.rectangleShape1.Name = "rectangleShape1";
this.rectangleShape1.Size = new System.Drawing.Size(109, 45);
//
// textBox1
//
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Location = new System.Drawing.Point(15, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(77, 13);
this.textBox1.TabIndex = 1;
//
// MyTextBox
//
this.Controls.Add(this.textBox1);
this.Controls.Add(this.shapeContainer1);
this.Name = "MyTextBox";
this.Size = new System.Drawing.Size(150, 55);
this.Resize += new System.EventHandler(this.MyTextBox_Resize);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void MyTextBox_Resize(object sender, EventArgs e)
{
Height = textBox1.Height + 4;
rectangleShape1.Location = new Point(0, 0);
rectangleShape1.Height = Height - 1;
rectangleShape1.Width = Width - 1;
textBox1.Location = new Point(3, 2);
textBox1.Width = Width - 6;
}
}
}
qqer dúvida poste a dúvida. _________________ Marcelo de Souza
Site: http://desenvolvedores.net
Minha filhota: http://luninha.com
IRC: Rede: irc.desenvolvedores.net
Canal: desenvolvedores
Voltar ao Topo
Enviar Mensagens Novas: Proibído . Responder Tópicos Proibído Editar Mensagens: Proibído . Excluir Mensagens: Proibído . Votar em Enquetes: Proibído .
Powered by phpBB © 2001, 2005 phpBB Group