PC Review


Reply
Thread Tools Rate Thread

DataTable.TableClearing Event doesn't fire when clearing empty tab

 
 
=?Utf-8?B?TXJTcG9jaw==?=
Guest
Posts: n/a
 
      23rd Nov 2005
According to the documentation TableClearing will be fired even when empty
tables are cleared:

"The TableClearing event is fired before processing of the Clear operation
begins. This event is always fired when the Clear method is invoked, even if
the table contains zero rows."

Add this code to a empty form:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Create table with one column
Dim dt As New DataTable
dt.Columns.Add("col1", System.Type.GetType("System.String"))

' Create row
Dim dr As DataRow = dt.NewRow
dr(0) = "val1"

' Add event handler
AddHandler dt.TableClearing, New
DataTableClearEventHandler(AddressOf TableClear)

' Clear table
dt.Clear()

' Add the row
dt.Rows.Add(dr)

' Clear table again
dt.Clear()
End Sub

Private Sub TableClear(ByVal sender As Object, ByVal e As
DataTableClearEventArgs)
MsgBox("Event fired!")
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

As you will see the event is only fired once, but I think it should be fired
twice. Is this a bug or have I done something wrong?
 
Reply With Quote
 
 
 
 
[MSFT]
Guest
Posts: n/a
 
      24th Nov 2005
Hello,

Based on my test, you are right at this issue. If DataTable has no record,
then when calling Clear() function, DataTableClearEventHandler was never
fired.

It seems to be a mistake in the document. Thank you for sharing the
experience in the community.

Luke


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fire and Event when row is added to a DataTable Marcolino Microsoft VB .NET 1 7th Mar 2009 01:55 AM
ImageButton event doesn't fire but Button event does suzanne.boyle@gmail.com Microsoft ASP .NET 4 13th Jun 2007 10:19 PM
Event doesn't fire =?Utf-8?B?RnJhbmsgWGlh?= Microsoft Excel Misc 6 11th Feb 2006 12:54 AM
OnDragEnter doesn't fire on empty TabControl Francois Vanderseypen Microsoft C# .NET 2 22nd Dec 2004 06:10 PM
OnDragEnter doesn't fire on empty TabControl Francois Vanderseypen Microsoft Dot NET Framework Forms 2 22nd Dec 2004 06:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 PM.