.NET控件如Outlook的电子邮件地址文本控制 [英] .NET Control like Outlook's E-mail Address Text Control

查看:170
本文介绍了.NET控件如Outlook的电子邮件地址文本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个控制一个.NET 2.0(窗口)的应用程序,就像在Outlook邮件窗口(如下蜜蜂)

I am looking for a control (or suggestions on building my own) for a .NET 2.0 (windows) app that works like the address box in the Outlook mail window (bee below)

控制基本工作原理,每个电子邮件地址就像是在文本区域的项目。我不那么在乎让用户还可以键入进入这个领域像您可以在Outlook中。我只是希望能够将这些完整的字符串(电子邮件地址)添加到文本区域或列表,用户可以选择他们(但不能编辑),可以在列表中删除或退格键删除整个项目(E -mail地址)。

The control basically works where each e-mail address is like an item in the text area. I don't care so much about letting the user also type into this area like you can in Outlook. I just want to be able to add these complete strings (e-mail addresses) to the text area, or list, and the user can select them (but not edit) and can delete or backspace through the list to delete entire items (e-mail addresses).

任何人都知道控制了那里,做到这一点的?为建设自己有什么建议? (或任何人知道你甚至称这种控制,所以我知道谷歌是什么?)

Anyone know of a control out there that does this? Any suggestions for building my own? (or anyone know what you even call this control so I know what to google?)

推荐答案

下面是一些代码,让你开始。

Here's some code to get you started.

using System.Text;
using System.Windows.Forms;
using System;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.Text = "mail@mail.com; mail2@mail.com; mail3@mail.com";
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            int nextSpaceIndex = textBox1.Text.Substring(textBox1.SelectionStart).IndexOf(' ');
            int firstSpaceIndex = textBox1.Text.Substring(0, textBox1.SelectionStart).LastIndexOf(' ');
            nextSpaceIndex = nextSpaceIndex == -1 ? textBox1.Text.Length : nextSpaceIndex + textBox1.SelectionStart;
            firstSpaceIndex = firstSpaceIndex == -1 ? 0 : firstSpaceIndex;
            textBox1.SelectionStart = firstSpaceIndex;
            textBox1.SelectionLength = nextSpaceIndex - firstSpaceIndex;
        }
    }
}

这意志,当你点击在一个电子邮件地址,选择整个电子邮件地址。我不知道这是否是你要去的(这听起来就像是,虽然)的功能,但它会帮助您开始。如果你想要做其他的事情以后有点击功能,勾成文本框提供的其他事件。

This will, when you click on an email address, select the entire email address. I'm not sure if this is the functionality you're going for (it sounds like it is, though), but it'll get you started. If you want to do other things beyond having click functionality, hook into the other events offered by TextBox.

这篇关于.NET控件如Outlook的电子邮件地址文本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆