码迷,mamicode.com
首页 > Windows程序 > 详细

15.13DataGridView单元格自动填充

时间:2016-04-21 21:49:53      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _15._13DataGridView单元格自动填充
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“csharpzxwDataSet.mytable001”中。您可以根据需要移动或删除它。
            this.mytable001TableAdapter.Fill(this.csharpzxwDataSet.mytable001);

        }

        private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            string titleText = dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText;
            if (titleText.Equals("department"))
            {
                TextBox autoText = e.Control as TextBox;
                if (autoText != null)
                {
                    autoText.AutoCompleteMode = AutoCompleteMode.Suggest;
                    autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
                    AutoCompleteStringCollection dataCollection = new AutoCompleteStringCollection();
                    dataCollection.Add("开发部");
                    dataCollection.Add("销售部");
                    dataCollection.Add("技术支持部");
                    dataCollection.Add("财务部");
                    autoText.AutoCompleteCustomSource = dataCollection;
                }
             
            }
        }
    }
}

 

15.13DataGridView单元格自动填充

标签:

原文地址:http://www.cnblogs.com/zqyo2000z/p/5418772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!