58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.MyControl
|
|
{
|
|
public partial class Myeditdgv : DataGridView
|
|
{
|
|
public Myeditdgv()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public Myeditdgv(IContainer container)
|
|
{
|
|
container.Add(this);
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Vasuneditdgv_SelectionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
BeginEdit(true);//更改为编辑状态
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void Vasuneditdgv_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
//CurrentCell.Style.ForeColor = Color.Red;//单元格内容被修改时改变单元格背景颜色为红
|
|
}
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)//回车键使datagridview列移动
|
|
{
|
|
if (keyData == Keys.Enter)
|
|
{
|
|
System.Windows.Forms.SendKeys.Send("{tab}");
|
|
return true;
|
|
}
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
}
|
|
|
|
private void Vasuneditdgv_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
BeginEdit(true);//更改为编辑状态
|
|
}
|
|
}
|
|
}
|