C#中datagridview的EditingControlShowing事件用法实例
作者:zhuzhao 时间:2021-05-27 23:08:43
本文实例讲述了C#中datagridview的EditingControlShowing事件用法。分享给大家供大家参考。具体实现方法如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using datagridview1.DataSet1TableAdapters;
namespace datagridview1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
CustomersTableAdapter adapter = new CustomersTableAdapter();
bindingSource1.DataSource = adapter.GetData();
dataGridView1.DataSource = bindingSource1;
}
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex < 0)
{
e.Graphics.FillRectangle(Brushes.White, e.CellBounds);
e.Handled = true;
}
}
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 1)
{
//e.CellStyle.BackColor = Color.FromName("window");
//DataGridViewComboBoxEditingControl editingControl = e.Control as DataGridViewComboBoxEditingControl;
DataGridViewTextBoxEditingControl editingControl = e.Control as DataGridViewTextBoxEditingControl;
editingControl.TextChanged += new EventHandler(editingControl_TextChanged);
}
}
void editingControl_TextChanged(object sender, EventArgs e)
{
this.label1.Text = dataGridView1.CurrentCell.EditedFormattedValue.ToString();
}
}
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,datagridview
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
解析Android横竖屏切换的问题
2021-07-20 11:37:58
Android USB转串口通信开发实例详解
2022-01-05 15:28:17
MyBatis动态SQL中的trim标签的使用方法
2022-08-30 21:38:13
android实现简易计算器
2023-06-21 04:26:09
![](https://img.aspxhome.com/file/2023/4/83514_0s.jpg)
详解如何实现SpringBoot的底层注解
2023-11-23 06:21:04
![](https://img.aspxhome.com/file/2023/0/59040_0s.png)
Android自定义控件之电话拨打小键盘
2022-11-17 21:52:08
![](https://img.aspxhome.com/file/2023/8/89518_0s.jpg)
java String的深入理解
2022-10-30 23:50:37
![](https://img.aspxhome.com/file/2023/5/69895_0s.png)
Android Jetpack组件中LifeCycle作用详细介绍
2022-05-14 04:56:15
![](https://img.aspxhome.com/file/2023/2/89542_0s.png)
Android自定义轮播图效果
2022-10-27 06:31:26
利用logback 设置不同包下的日志级别
2022-08-11 20:05:43
Android编程实现AlertDialog自定义弹出对话框的方法示例
2022-09-13 19:34:45
JavaWeb实现注册用户名检测
2022-07-20 05:25:46
![](https://img.aspxhome.com/file/2023/7/92687_0s.jpg)
解决java执行cmd命令调用ffmpeg报错Concat error - No such filter '[0,0]'问题
2023-03-14 20:35:11
![](https://img.aspxhome.com/file/2023/4/101924_0s.png)
Android 调用发送短信的方法
2023-05-30 22:56:40
Scala可变参数列表,命名参数和参数缺省详解
2022-09-26 21:00:49
JAVA基于数组实现的商品信息查询功能示例
2021-10-31 11:47:23
JavaWeb中使用JavaMail实现发送邮件功能实例详解
2023-01-07 13:54:37
![](https://img.aspxhome.com/file/2023/1/60821_0s.png)
C# DataSet查看返回结果集的实现
2021-10-10 09:54:31
![](https://img.aspxhome.com/file/2023/1/111091_0s.png)
.net的命名空间类库的简单介绍
2023-01-19 17:56:27
Java使用join方法暂停当前线程
2023-11-03 04:32:31