C#中datagridview的EditingControlShowing事件用法實(shí)例
更新時(shí)間:2015年06月24日 09:53:18 作者:zhuzhao
這篇文章主要介紹了C#中datagridview的EditingControlShowing事件用法,實(shí)例分析了datagridview的EditingControlShowing事件的定義與使用技巧,需要的朋友可以參考下
本文實(shí)例講述了C#中datagridview的EditingControlShowing事件用法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
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();
}
}
}
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
C#以太網(wǎng)Sockets服務(wù)器設(shè)計(jì)實(shí)現(xiàn)
本文主要介紹了C#以太網(wǎng)Sockets服務(wù)器設(shè)計(jì)實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02
C#將數(shù)字轉(zhuǎn)換成字節(jié)數(shù)組的方法
這篇文章主要介紹了C#將數(shù)字轉(zhuǎn)換成字節(jié)數(shù)組的方法,涉及C#字符串操作的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04
C# WinForm實(shí)現(xiàn)窗體上控件自由拖動(dòng)功能示例
這篇文章主要介紹了C# WinForm實(shí)現(xiàn)窗體上控件自由拖動(dòng)功能,涉及WinForm控件屬性及事件響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下2017-07-07
c#的時(shí)間日期操作示例分享(c#獲取當(dāng)前日期)
這篇文章主要介紹了c#的時(shí)間日期操作示例,在給定時(shí)間戳返回指定的時(shí)間格式和獲取當(dāng)前時(shí)間方法,需要的朋友可以參考下2014-03-03
淺談Visual C#進(jìn)行圖像處理(讀取、保存以及對(duì)像素的訪問(wèn))
本文主要介紹利用C#對(duì)圖像進(jìn)行讀取、保存以及對(duì)像素的訪問(wèn)等操作,介紹的比較簡(jiǎn)單,希望對(duì)初學(xué)者有所幫助。2016-04-04

