• 大小: 58KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-17
  • 语言: C#
  • 标签: csharp  

资源简介

c# DataGridView中添加下拉列表! 很值得下载看看!资源免费,大家分享!!

资源截图

代码片段和文件信息

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

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        // 定义下拉列表框
        private ComboBox cmb_Temp = new ComboBox();

        /// 
        /// 绑定性别下拉列表框
        /// 

        private void BindSex()
        {
            DataTable dtSex = new DataTable();
            dtSex.Columns.Add(“Value“);
            dtSex.Columns.Add(“Name“);
            DataRow drSex;
            drSex = dtSex.NewRow();
            drSex[0] = “1“;
            drSex[1] = “男“;
            dtSex.Rows.Add(drSex);
            drSex = dtSex.NewRow();
            drSex[0] = “0“;
            drSex[1] = “女“;
            dtSex.Rows.Add(drSex);
            cmb_Temp.ValueMember = “Value“;
            cmb_Temp.DisplayMember = “Name“;
            cmb_Temp.DataSource = dtSex;
            //cmb_Temp.DropDownstyle = ComboBoxstyle.DropDownList;
        }

        private void BindData()
        {
            DataTable dtData = new DataTable();
            dtData.Columns.Add(“ID“);
            dtData.Columns.Add(“Name“);
            dtData.Columns.Add(“Sex“);
            DataRow drData;
            drData = dtData.NewRow();
            drData[0] = 1;
            drData[1] = “张三“;
            drData[2] = “1“;
            dtData.Rows.Add(drData);
            drData = dtData.NewRow();
            drData[0] = 2;
            drData[1] = “李四“;
            drData[2] = “1“;
            dtData.Rows.Add(drData);
            drData = dtData.NewRow();
            drData[0] = 3;
            drData[1] = “王五“;
            drData[2] = “1“;
            dtData.Rows.Add(drData);
            drData = dtData.NewRow();
            drData[0] = 4;
            drData[1] = “小芳“;
            drData[2] = “0“;
            dtData.Rows.Add(drData);
            drData = dtData.NewRow();
            drData[0] = 5;
            drData[1] = “小娟“;
            drData[2] = “0“;
            dtData.Rows.Add(drData);
            drData = dtData.NewRow();
            drData[0] = 6;
            drData[1] = “赵六“;
            drData[2] = “1“;
            dtData.Rows.Add(drData);
            this.dataGridView1.DataSource = dtData;
        }

        private void Form1_Load(object sender EventArgs e)
        {
            // 绑定性别下拉列表框
            BindSex();

            //绑定数据表
            BindData();

            //// 设置下拉列表框不可见
            //cmb_Temp.Visible = false;

            //// 添加下拉列表框事件
            cmb_Temp.SelectedIndexChanged += new EventHandler(cmb_Temp_SelectedIndexChanged);

            // 将下拉列表框加入到DataGridView控件中
            this.dataGridView1.Controls.Add(cmb_Temp);

        }

        private void dataGridView1_CurrentCellChanged(obje

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5612  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Properties\Resources.resx

     文件        249  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Properties\Settings.settings

     文件       1210  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Properties\AssemblyInfo.cs

     文件       2893  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Properties\Resources.Designer.cs

     文件       1103  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Properties\Settings.Designer.cs

     文件       3245  2008-07-15 04:24  c# DataGridView中添加下拉列表\WindowsApplication1\WindowsApplication1.csproj

     文件       5632  2005-11-11 22:25  c# DataGridView中添加下拉列表\WindowsApplication1\bin\Debug\WindowsApplication1.vshost.exe

     文件      24576  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\bin\Debug\WindowsApplication1.exe

     文件      28160  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\bin\Debug\WindowsApplication1.pdb

     文件        180  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug\WindowsApplication1.Form1.resources

     文件        180  2008-07-15 04:35  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug\WindowsApplication1.Properties.Resources.resources

     文件      28160  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug\WindowsApplication1.pdb

     文件      24576  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug\WindowsApplication1.exe

     文件        842  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug\WindowsApplication1.csproj.GenerateResource.Cache

     文件        352  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\obj\WindowsApplication1.csproj.FileList.txt

     文件        478  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Program.cs

     文件       6043  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\Form1.cs

     文件       2635  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\Form1.Designer.cs

     文件       5814  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1\Form1.resx

     文件        946  2008-07-15 04:20  c# DataGridView中添加下拉列表\WindowsApplication1.sln

    ..A..H.     12288  2008-07-15 06:12  c# DataGridView中添加下拉列表\WindowsApplication1.suo

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug\TempPE

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\bin\Debug

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\obj\Debug

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\Properties

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\bin

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1\obj

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表\WindowsApplication1

     目录          0  2008-07-15 04:19  c# DataGridView中添加下拉列表

     文件     446270  2008-11-07 13:21  更多免费精品资源:点击访问.url

............此处省略3个文件信息

评论

共有 条评论