Form1.cs
上传用户:cpw91211
上传日期:2021-01-18
资源大小:46k
文件大小:1k
源码类别:

组合框控件

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace CustomComboDemo
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         public Form1()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.         private void Form1_Load(object sender, EventArgs e)
  18.         {
  19.             // Dynamically created controls.
  20.             // Create grid view control.
  21.             DataGridView gridView = new DataGridView();
  22.             gridView.BorderStyle = BorderStyle.None;
  23.             gridView.Columns.Add("Column1", "Column 1");
  24.             gridView.Columns.Add("Column2", "Column 2");
  25.             gridView.Columns.Add("Column3", "Column 3");
  26.             gridView.Columns.Add("Column4", "Column 4");
  27.             gridView.Columns.Add("Column5", "Column 5");
  28.             this.customComboBox1.DropDownControl = gridView;
  29.             // Create user control.
  30.             UserControl1 userControl = new UserControl1();
  31.             userControl.BorderStyle = BorderStyle.None;
  32.             this.customComboBox2.DropDownControl = userControl;
  33.             // Create rich textbox control.
  34.             RichTextBox richTextBox = new RichTextBox();
  35.             richTextBox.BorderStyle = BorderStyle.None;
  36.             this.customComboBox3.DropDownControl = richTextBox;
  37.         }
  38.     }
  39. }