"Tab.Columns" 的 "Tab" 在此代码中的含义
What "Tab" of "Tab.Columns" means on this code
我正在尝试将我在 Here 中找到的 C# 代码翻译成 VB。我非常成功,但在 foreach(DataColumn C in Tab.Columns)
.
中遇到 Tab
的问题
显然它不是全局变量...但他没有在任何地方定义它。
方法是这个:
private void My_OnRowUpdate(object sender, OleDbRowUpdatedEventArgs e)
{
if(e.StatementType==StatementType.Insert)
{
// reads the identity value from the output parameter @ID
object ai = e.Command.Parameters["@ID"].Value;
// updates the identity column (autoincrement)
foreach(DataColumn C in Tab.Columns)
{
if(C.AutoIncrement)
{
C.ReadOnly = false;
e.Row[C] = ai;
C.ReadOnly = true;
break; // there can be only one identity column
}
}
e.Row.AcceptChanges();
}
}
也许我误解了什么?
由于 RowUpdated
事件通过 OleDbRowUpdatedEventArgs
as argument you can simply use it's Row
属性 获得对 table 的引用。这比文章中的更好:
private void My_OnRowUpdate(object sender, OleDbRowUpdatedEventArgs e)
{
if(e.StatementType==StatementType.Insert)
{
// reads the identity value from the output parameter @ID
object ai = e.Command.Parameters["@ID"].Value;
// updates the identity column (autoincrement)
foreach(DataColumn C in e.Row.Table.Columns)
{
if(C.AutoIncrement)
{
C.ReadOnly = false;
e.Row[C] = ai;
C.ReadOnly = true;
break; // there can be only one identity column
}
}
e.Row.AcceptChanges();
}
}
我正在尝试将我在 Here 中找到的 C# 代码翻译成 VB。我非常成功,但在 foreach(DataColumn C in Tab.Columns)
.
Tab
的问题
显然它不是全局变量...但他没有在任何地方定义它。
方法是这个:
private void My_OnRowUpdate(object sender, OleDbRowUpdatedEventArgs e)
{
if(e.StatementType==StatementType.Insert)
{
// reads the identity value from the output parameter @ID
object ai = e.Command.Parameters["@ID"].Value;
// updates the identity column (autoincrement)
foreach(DataColumn C in Tab.Columns)
{
if(C.AutoIncrement)
{
C.ReadOnly = false;
e.Row[C] = ai;
C.ReadOnly = true;
break; // there can be only one identity column
}
}
e.Row.AcceptChanges();
}
}
也许我误解了什么?
由于 RowUpdated
事件通过 OleDbRowUpdatedEventArgs
as argument you can simply use it's Row
属性 获得对 table 的引用。这比文章中的更好:
private void My_OnRowUpdate(object sender, OleDbRowUpdatedEventArgs e)
{
if(e.StatementType==StatementType.Insert)
{
// reads the identity value from the output parameter @ID
object ai = e.Command.Parameters["@ID"].Value;
// updates the identity column (autoincrement)
foreach(DataColumn C in e.Row.Table.Columns)
{
if(C.AutoIncrement)
{
C.ReadOnly = false;
e.Row[C] = ai;
C.ReadOnly = true;
break; // there can be only one identity column
}
}
e.Row.AcceptChanges();
}
}