日期:2014-05-18  浏览次数:20810 次

用C# 怎么如何设计一个类似QQ的个性签名输入框
最近在做类似QQ的聊天软件,其他功能都基本实现了,但是我突然发现关于个性签名的输入框的设计没有出来,所以想请大家帮帮忙,指导我一下,怎么实现类似QQ的个性签名的输入框

------解决方案--------------------
不就是标签+文本框嘛
点击标签显示文本框
输入完又把文本框隐藏显示标签



------解决方案--------------------
C# code
using System;
using System.Windows.Forms;

namespace WindowsFormsApplication5
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();

            LableEdit lableEdit = new LableEdit();
            this.Controls.Add(lableEdit);
        }
    }

    public class LableEdit : UserControl
    {
        private Label _lbl;
        private TextBox _txt;

        public LableEdit()
        {
            _lbl = new Label();
            _lbl.Dock = DockStyle.Fill;
            _lbl.Click += LableClick;
            _lbl.Visible = true;
            _lbl.Text = "SocketUp";

            _txt = new TextBox();
            _txt.Dock = DockStyle.Fill;
            _txt.KeyUp += TextboxKeyUp;
            _txt.Visible = false;
            _txt.BorderStyle = BorderStyle.None;

            this.Controls.Add(_lbl);
            this.Controls.Add(_txt);
        }

        private void LableClick(object sender, EventArgs e)
        {
            _lbl.Visible = false;
            _txt.Visible = true;
            _txt.Text = _lbl.Text;
            _txt.Focus();
        }

        private void TextboxKeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                _lbl.Visible = true;
                _txt.Visible = false;
                _lbl.Text = _txt.Text;
            }
        }
    }
}

------解决方案--------------------
DotnetBar 的textBox有个属性能实现楼主的要求!你看看