5.只能輸入數值的DataGridTextBoxColumn
C# 部分
public class DataGridDigitsTextBoxColumn : DataGridTextBoxColumn
{
public DataGridDigitsTextBoxColumn(System.ComponentModel.PropertyDescriptor pd, string format, bool b)
: base(pd, format, b)
{
this.TextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(HandleKeyPress);
}
private void HandleKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
//ignore if not digit or control key
if(!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
e.Handled = true;
//ignore if more than 3 digits
if(this.TextBox.Text.Length >= 3 && !char.IsControl(e.KeyChar) && this.TextBox.SelectionLength == 0)
e.Handled = true;
}
3.EXcel的設定方面,獲取正在Excel.Application。book‘name
:>你肯定要開個Excel 應用程序先,該那個book的name為"Haha"
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
REM Dim xlSheet As Excel.Worksheet
Dim myBookName As String