P
Paul Guides
Hi,
my app has a ComboBox bound to a DataTable.
When doing removing all rows by suing this code:
public static void RemoveAllRows( DataSet ds, string tabName ) {
try {
DataTable tab = ds.Tables[ tabName ];
// does not help: tab.BeginInit();
// does not help: tab.BeginLoadData();
DataRowCollection rc = tab.Rows;
rc.Clear();
// does not help: tab.EndLoadData();
// does not help: tab.EndInit();
}
catch( Exception ex ) {
Apt.Exception( "RemoveAllRows: " + tabName, ex );
}
}
There will always be an exception deep inside some databinding
code, which is no wonder because all records where removed and
the ComboBox cannot access the row with index 0.
The exceptions says: + "There is no row at position 0.", which
is right.
So I ask: How can one turn off data binding?
The table will be cleared, then reloaed. And i want to turn
DB off before clearing it and turn it on after loading
Any ideas?
Paul
PS: The call stack
system.data.dll!System.Data.DataView.GetRecord(int recordIndex = 0) + 0x27
bytes
system.data.dll!System.Data.DataView.IsOriginalVersion(int index = 0) +
0x21 bytes
system.data.dll!System.Data.DataRowView.GetColumnValue(System.Data.DataColum
n column = {System.Data.DataColumn}) + 0x22 bytes
system.data.dll!System.Data.DataColumnPropertyDescriptor.GetValue(System.Obj
ect component = {System.Data.DataRowView}) + 0x31 bytes
system.windows.forms.dll!System.Windows.Forms.ListControl.FilterItemOnProper
ty(System.Object item = {System.Data.DataRowView}, string field =
"Nachname") + 0x97 bytes
system.windows.forms.dll!System.Windows.Forms.ListControl.FilterItemOnProper
ty(System.Object item = {System.Data.DataRowView}) + 0x29 bytes
system.windows.forms.dll!System.Windows.Forms.ComboBox.set_Text(string
value = "") + 0x11d bytes
system.windows.forms.dll!System.Windows.Forms.ComboBox.UpdateText() + 0x73
bytes
system.windows.forms.dll!System.Windows.Forms.ComboBox.set_SelectedIndex(int
value = -1) + 0x10e bytes
system.windows.forms.dll!System.Windows.Forms.ListControl.DataManager_Positi
onChanged(System.Object sender =
{System.Windows.Forms.RelatedCurrencyManager}, System.EventArgs e =
{System.EventArgs}) + 0x28 bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnPositionChan
ged(System.EventArgs e = {System.EventArgs}) + 0x37 bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordSt
ate(int newPosition = -1, bool validating = false, bool endCurrentEdit =
true, bool firePositionChange = true, bool pullData = false) + 0x6c bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
g(bool force = false) + 0xd0 bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
g() + 0xd bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.List_ListChang
ed(System.Object sender = {System.Data.DataView},
System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs}) + 0x44 bytes
system.data.dll!System.Data.DataView.OnListChanged(System.ComponentModel.Lis
tChangedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x48
bytes
system.data.dll!System.Data.DataView.IndexListChanged(System.Object sender
= {System.Data.Index}, System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs}) + 0x43 bytes
system.data.dll!System.Data.DataView.FireEvent(System.Data.TargetEvent
targetEvent = IndexListChanged, System.Object sender = {System.Data.Index},
System.EventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x4c
bytes
system.data.dll!System.Data.DataViewListener.IndexListChanged(System.Object
sender = {System.Data.Index}, System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs}) + 0x3d bytes
system.data.dll!System.Data.Index.OnListChanged(System.ComponentModel.ListCh
angedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x29
bytes
system.data.dll!System.Data.Index.Reset() + 0x1c bytes
system.data.dll!System.Data.DataTable.ResetIndexes() + 0x6c bytes
system.data.dll!System.Data.DataTable.Clear() + 0x180 bytes
system.data.dll!System.Data.DataRowCollection.Clear() + 0x11 bytes
my app has a ComboBox bound to a DataTable.
When doing removing all rows by suing this code:
public static void RemoveAllRows( DataSet ds, string tabName ) {
try {
DataTable tab = ds.Tables[ tabName ];
// does not help: tab.BeginInit();
// does not help: tab.BeginLoadData();
DataRowCollection rc = tab.Rows;
rc.Clear();
// does not help: tab.EndLoadData();
// does not help: tab.EndInit();
}
catch( Exception ex ) {
Apt.Exception( "RemoveAllRows: " + tabName, ex );
}
}
There will always be an exception deep inside some databinding
code, which is no wonder because all records where removed and
the ComboBox cannot access the row with index 0.
The exceptions says: + "There is no row at position 0.", which
is right.
So I ask: How can one turn off data binding?
The table will be cleared, then reloaed. And i want to turn
DB off before clearing it and turn it on after loading
Any ideas?
Paul
PS: The call stack
system.data.dll!System.Data.DataView.GetRecord(int recordIndex = 0) + 0x27
bytes
system.data.dll!System.Data.DataView.IsOriginalVersion(int index = 0) +
0x21 bytes
system.data.dll!System.Data.DataRowView.GetColumnValue(System.Data.DataColum
n column = {System.Data.DataColumn}) + 0x22 bytes
system.data.dll!System.Data.DataColumnPropertyDescriptor.GetValue(System.Obj
ect component = {System.Data.DataRowView}) + 0x31 bytes
system.windows.forms.dll!System.Windows.Forms.ListControl.FilterItemOnProper
ty(System.Object item = {System.Data.DataRowView}, string field =
"Nachname") + 0x97 bytes
system.windows.forms.dll!System.Windows.Forms.ListControl.FilterItemOnProper
ty(System.Object item = {System.Data.DataRowView}) + 0x29 bytes
system.windows.forms.dll!System.Windows.Forms.ComboBox.set_Text(string
value = "") + 0x11d bytes
system.windows.forms.dll!System.Windows.Forms.ComboBox.UpdateText() + 0x73
bytes
system.windows.forms.dll!System.Windows.Forms.ComboBox.set_SelectedIndex(int
value = -1) + 0x10e bytes
system.windows.forms.dll!System.Windows.Forms.ListControl.DataManager_Positi
onChanged(System.Object sender =
{System.Windows.Forms.RelatedCurrencyManager}, System.EventArgs e =
{System.EventArgs}) + 0x28 bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnPositionChan
ged(System.EventArgs e = {System.EventArgs}) + 0x37 bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordSt
ate(int newPosition = -1, bool validating = false, bool endCurrentEdit =
true, bool firePositionChange = true, bool pullData = false) + 0x6c bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
g(bool force = false) + 0xd0 bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
g() + 0xd bytes
system.windows.forms.dll!System.Windows.Forms.CurrencyManager.List_ListChang
ed(System.Object sender = {System.Data.DataView},
System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs}) + 0x44 bytes
system.data.dll!System.Data.DataView.OnListChanged(System.ComponentModel.Lis
tChangedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x48
bytes
system.data.dll!System.Data.DataView.IndexListChanged(System.Object sender
= {System.Data.Index}, System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs}) + 0x43 bytes
system.data.dll!System.Data.DataView.FireEvent(System.Data.TargetEvent
targetEvent = IndexListChanged, System.Object sender = {System.Data.Index},
System.EventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x4c
bytes
system.data.dll!System.Data.DataViewListener.IndexListChanged(System.Object
sender = {System.Data.Index}, System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs}) + 0x3d bytes
system.data.dll!System.Data.Index.OnListChanged(System.ComponentModel.ListCh
angedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x29
bytes
system.data.dll!System.Data.Index.Reset() + 0x1c bytes
system.data.dll!System.Data.DataTable.ResetIndexes() + 0x6c bytes
system.data.dll!System.Data.DataTable.Clear() + 0x180 bytes
system.data.dll!System.Data.DataRowCollection.Clear() + 0x11 bytes
{System.Data.DataSet}, string tabName = "KundenAPs") Line 407 C#kwtools.dll!KwTools.Data.RemoveAllRows(System.Data.DataSet ds =