問題:
我們來作一個 FULL JOIN 查詢:
解決:
LEFT JOIN, RIGHT JOIN Operations (Microsoft Access SQL)
[数据库] ACCESS中不支持FULL JOIN的解决方案 
Full Outer Join in MS Access
2015年6月10日 星期三
[除錯] DataGridView RowValidating事件, 當按Escape取消時, 不要引發該事件...
as title...
參考:
Escaping DataGridView Row creation fires RowValidating. How to avoid this?
參考:
Escaping DataGridView Row creation fires RowValidating. How to avoid this?
1)
private void dataGridView1_KeyDown(object sender, KeyEventArgs e) 
{ 
     if (e.KeyCode == Keys.Escape) 
     { 
          this.dataGridView1.RowValidating -= 
               new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView1_RowValidating); 
     } 
     this.dataGridView1.RowValidating += 
          new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView1_RowValidating); 
}
2)
if (!view.IsCurrentRowDirty ) return; 
2015年4月10日 星期五
2015年2月12日 星期四
[學習] 在C#實現VB函式【IsNumeric】
【CODE】
【CODE】
參考:
判断一个字符串是否全是数字的多种方法及其性能比较(C#实现)
[C#]IsNumeric 判斷是否為數值
[C#]數值驗證 IsNumeric
C# Equivalent of VB's IsNumeric()
C# IsNumeric
C#的判斷是否為數字,難道只能用Try、Catch嗎?..沒有VB.NET的IsNumeric可用嗎
static bool IsNumeric(object Expression)
{
// Variable to collect the Return value of the TryParse method.
bool isNum;
// Define variable to collect out parameter of the TryParse method. If the conversion fails, the out parameter is zero.
double retNum;
// The TryParse method converts a string in a specified style and culture-specific format to its double-precision floating point number equivalent.
// The TryParse method does not generate an exception if the conversion fails. If the conversion passes, True is returned. If it does not, False is returned.
isNum = Double.TryParse(Convert.ToString(Expression), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);
return isNum;
}
【CODE】
public static bool IsNum(String str)
{
for (int i = 0; i < str.Length; i++)
{
if (str[i] < '0' || str[i] > '9')
return false;
}
return true;
}
參考:
判断一个字符串是否全是数字的多种方法及其性能比较(C#实现)
[C#]IsNumeric 判斷是否為數值
[C#]數值驗證 IsNumeric
C# Equivalent of VB's IsNumeric()
C# IsNumeric
C#的判斷是否為數字,難道只能用Try、Catch嗎?..沒有VB.NET的IsNumeric可用嗎
2015年1月29日 星期四
[學習] MenuStrip 合併菜單
除錯:
mdiParent的MenuStrip若設定 Ctrl-X 等文字編輯快捷鍵時,當mdiChildren無MenuStrip設定...
則該視窗的 RichTextbox 會因 mdiParent 的快捷鍵設定而失效...
解決:
直接在mdiChildren設定MenuStrip並設定與mdiParent第一格相同的名稱,
並將該格enable設為false,MergeAction=Replace,MergeIndex設為要取代MenuStrip某欄的Index
無需再設定任何快捷鍵...
則RichTextbox的文字編輯快捷鍵立即復活...
參考:
【转】menustrip控件中mergeaction属性的作用
在 Windows 窗体 MenuStrip 控件中合并菜单项
合併 Windows Form MenuStrip 控制項中的功能表項目
mdiParent的MenuStrip若設定 Ctrl-X 等文字編輯快捷鍵時,當mdiChildren無MenuStrip設定...
則該視窗的 RichTextbox 會因 mdiParent 的快捷鍵設定而失效...
解決:
直接在mdiChildren設定MenuStrip並設定與mdiParent第一格相同的名稱,
並將該格enable設為false,MergeAction=Replace,MergeIndex設為要取代MenuStrip某欄的Index
無需再設定任何快捷鍵...
則RichTextbox的文字編輯快捷鍵立即復活...
參考:
【转】menustrip控件中mergeaction属性的作用
在 Windows 窗体 MenuStrip 控件中合并菜单项
合併 Windows Form MenuStrip 控制項中的功能表項目
2015年1月20日 星期二
[學習] 從一個datatable找某column的最大值
運用linq + lambda
或直接用datatable的彙總函式
e.Row.Cells("收退序號").Value = If(dgv_單據明細.Rows.Count > 1,
tbl.Compute("max(收退序號)",
"管理模式編號=" & cbo_管理模式編號.SelectedValue & _
" AND 收退單號='" & txt_收退單號.Text & "'") + 1,
1)
參考:
從查詢中建立 DataTable (LINQ to DataSet)
單一資料表查詢 (LINQ to DataSet)
DataTable: Get Max Value Using LINQ With Criteria Field (GroupBy)
How to select min and max values of a column in a datatable?
DataTable.Compute 方法
或直接用datatable的彙總函式
e.Row.Cells("收退序號").Value = If(dgv_單據明細.Rows.Count > 1,
tbl.Compute("max(收退序號)",
"管理模式編號=" & cbo_管理模式編號.SelectedValue & _
" AND 收退單號='" & txt_收退單號.Text & "'") + 1,
1)
參考:
從查詢中建立 DataTable (LINQ to DataSet)
單一資料表查詢 (LINQ to DataSet)
DataTable: Get Max Value Using LINQ With Criteria Field (GroupBy)
How to select min and max values of a column in a datatable?
DataTable.Compute 方法
[學習] 當二個以上Combobox繫結相同來源時,若其中一個改變選項,則其它相同參考的Combobox不隨之改變....
程式:[用不同的BindingContext就好了]
If MyUserProgInfo.frmLogin使用WebServices Then
cbo_單據別1.DataSource = ws.ItemtblB備案手冊單據別基本資料表_GetMdl()
Else
cbo_單據別1.DataSource = New BLLMSSQL.BllBasicCtrlsSource().ItemtblB備案手冊單據別基本資料表
End If
cbo_單據別1.DisplayMember = "DisplayValue"
cbo_單據別1.ValueMember = "單據別"
cbo_單據別2.BindingContext = New BindingContext()
cbo_單據別2.DataSource = cbo_單據別1.DataSource
cbo_單據別2.DisplayMember = "DisplayValue"
cbo_單據別2.ValueMember = "單據別"
參考:
WinForms ComboBox data binding gotcha
Multiple Combo Boxes With The Same Data Source (C#)
BindingContext 類別
关于控件使用DataBindings.Add方法进行简单绑定的问题
Bind multiple ComboBox to a single List - Issue: When I select an item, all combo boxes change
WinForm数据绑定--BindingContext
How can i bind data to a datagridview combobox column?
You could create a BindingList<> object to hold your objects and then bind that list to the three controls. Then setting the BindingContexts to different objects would let the 3 controls have different positions with a single list.
  
 
 
 
 
 
 
 
If MyUserProgInfo.frmLogin使用WebServices Then
cbo_單據別1.DataSource = ws.ItemtblB備案手冊單據別基本資料表_GetMdl()
Else
cbo_單據別1.DataSource = New BLLMSSQL.BllBasicCtrlsSource().ItemtblB備案手冊單據別基本資料表
End If
cbo_單據別1.DisplayMember = "DisplayValue"
cbo_單據別1.ValueMember = "單據別"
cbo_單據別2.BindingContext = New BindingContext()
cbo_單據別2.DataSource = cbo_單據別1.DataSource
cbo_單據別2.DisplayMember = "DisplayValue"
cbo_單據別2.ValueMember = "單據別"
參考:
WinForms ComboBox data binding gotcha
Multiple Combo Boxes With The Same Data Source (C#)
BindingContext 類別
关于控件使用DataBindings.Add方法进行简单绑定的问题
Bind multiple ComboBox to a single List - Issue: When I select an item, all combo boxes change
WinForm数据绑定--BindingContext
How can i bind data to a datagridview combobox column?
You could create a BindingList<> object to hold your objects and then bind that list to the three controls. Then setting the BindingContexts to different objects would let the 3 controls have different positions with a single list.
public partial class Form1 : Form  {  public Form1()  {    InitializeComponent();  }  private void Form1_Load(object sender, EventArgs e)  {    BindingList<MyObject> list = new BindingList<MyObject>();    list.Add(new MyObject("Ramya", 43));    list.Add(new MyObject("Manju", 43));    list.Add(new MyObject("Gulnus", 43));    list.Add(new MyObject("Sona", 43));    dataGridView1.DataSource = list;    comboBox1.DataSource = list;    comboBox1.DisplayMember = "Name";    comboBox1.ValueMember = "Name";    comboBox2.DataSource = list;    comboBox2.DisplayMember = "Name";    comboBox2.ValueMember = "Name";    comboBox1.BindingContext = new BindingContext();    comboBox2.BindingContext = new BindingContext();    dataGridView1.BindingContext = new BindingContext();  }  }  public class MyObject  {  private string mName;  private int mAge;  public MyObject(string s, int i)  {    mName = s;    mAge = i;  }  public string Name  {    get { return mName; }    set { mName = value; }  }  public int Age  {    get { return mAge; }    set { mAge = value; }  }  public override string ToString()  {    return Name;  }  }
訂閱:
意見 (Atom)