A
ABC - Sébastien Beaugrand
Hi,
I've been trying to get an answer from french newsgroup but I did'nt succeed
in this, so I'll try on this group and sorry for my poor english.
The description of the bug :
The CurrentChanged event from the BindinManager on a Winform never occurs
with framework V1.1. and it is not possible from the bindings to know if
the user has done some modifications.
With framework V1.0 it was OK
You can find after a sample to reproduce this bug. You just have to play
this a first time with framework 1.0 to see that if you change anything in
the form you got a messagebox.
If you set the framework to V1.1 in your project and play it, you'll notice
that the event is not raised by the framework.
The project is made of a simple form (form1) with 2 textbox for displayiong
data. It is running on Pubs database from SQL Server running on local.
I would like to know if this bug is known from Microsoft Team and if a Patch
exists for this or is planned ?
Thank you,
Sebastien
'*************** CODE SAMPLE FORM FORM1
****************************************************
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(40, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(40, 40)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.TabIndex = 1
Me.TextBox2.Text = "TextBox2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim WithEvents MyBindingManager As BindingManagerBase
Dim ds As New DataSet
Dim dt As New DataTable
Private Sub MyBindingManager_CurrentChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyBindingManager.CurrentChanged
MsgBox("Modification des données")
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim CNX As String
Dim ds As DataSet
CNX = "Integrated Security=SSPI;Initial Catalog=Pubs;Data Source=127.0.0.1"
ds = ExecuteSQL("select top 10 * from authors", CNX, , True)
dt = ds.Tables(0)
Me.TextBox1.DataBindings.Clear()
Me.TextBox1.DataBindings.Add("Text", dt, "au_fname")
Me.TextBox2.DataBindings.Clear()
Me.TextBox2.DataBindings.Add("Text", dt, "au_lname")
MyBindingManager = Me.BindingContext.Item(dt)
End Sub
Public Function ExecuteSQL(ByVal sSql As String, ByVal ConnectionString As
String, Optional ByVal TimeOut As Integer = 30, Optional ByVal
DisplayErrorMessages As Boolean = False) As Data.DataSet
Dim Conn As SqlConnection
Dim selectCMD As SqlCommand
Dim da As SqlDataAdapter
Dim ds As Data.DataSet
Try
Conn = New SqlConnection(ConnectionString)
selectCMD = New SqlCommand(sSql, Conn)
selectCMD.CommandTimeout = TimeOut
da = New SqlDataAdapter
da.SelectCommand = selectCMD
Conn.Open()
ds = New DataSet
da.Fill(ds, "ROWSET")
Conn.Close()
Catch
If DisplayErrorMessages = True Then
Call MsgBox("Err : " & Err.Number & vbCrLf & "Description : " &
Err.Description, MsgBoxStyle.Critical, "Erreur d'accès aux données")
End If
End Try
Return ds
End Function
End Class
'*************** END OF CODE OF FORM1
*****************************************
I've been trying to get an answer from french newsgroup but I did'nt succeed
in this, so I'll try on this group and sorry for my poor english.
The description of the bug :
The CurrentChanged event from the BindinManager on a Winform never occurs
with framework V1.1. and it is not possible from the bindings to know if
the user has done some modifications.
With framework V1.0 it was OK
You can find after a sample to reproduce this bug. You just have to play
this a first time with framework 1.0 to see that if you change anything in
the form you got a messagebox.
If you set the framework to V1.1 in your project and play it, you'll notice
that the event is not raised by the framework.
The project is made of a simple form (form1) with 2 textbox for displayiong
data. It is running on Pubs database from SQL Server running on local.
I would like to know if this bug is known from Microsoft Team and if a Patch
exists for this or is planned ?
Thank you,
Sebastien
'*************** CODE SAMPLE FORM FORM1
****************************************************
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(40, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(40, 40)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.TabIndex = 1
Me.TextBox2.Text = "TextBox2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim WithEvents MyBindingManager As BindingManagerBase
Dim ds As New DataSet
Dim dt As New DataTable
Private Sub MyBindingManager_CurrentChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyBindingManager.CurrentChanged
MsgBox("Modification des données")
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim CNX As String
Dim ds As DataSet
CNX = "Integrated Security=SSPI;Initial Catalog=Pubs;Data Source=127.0.0.1"
ds = ExecuteSQL("select top 10 * from authors", CNX, , True)
dt = ds.Tables(0)
Me.TextBox1.DataBindings.Clear()
Me.TextBox1.DataBindings.Add("Text", dt, "au_fname")
Me.TextBox2.DataBindings.Clear()
Me.TextBox2.DataBindings.Add("Text", dt, "au_lname")
MyBindingManager = Me.BindingContext.Item(dt)
End Sub
Public Function ExecuteSQL(ByVal sSql As String, ByVal ConnectionString As
String, Optional ByVal TimeOut As Integer = 30, Optional ByVal
DisplayErrorMessages As Boolean = False) As Data.DataSet
Dim Conn As SqlConnection
Dim selectCMD As SqlCommand
Dim da As SqlDataAdapter
Dim ds As Data.DataSet
Try
Conn = New SqlConnection(ConnectionString)
selectCMD = New SqlCommand(sSql, Conn)
selectCMD.CommandTimeout = TimeOut
da = New SqlDataAdapter
da.SelectCommand = selectCMD
Conn.Open()
ds = New DataSet
da.Fill(ds, "ROWSET")
Conn.Close()
Catch
If DisplayErrorMessages = True Then
Call MsgBox("Err : " & Err.Number & vbCrLf & "Description : " &
Err.Description, MsgBoxStyle.Critical, "Erreur d'accès aux données")
End If
End Try
Return ds
End Function
End Class
'*************** END OF CODE OF FORM1
*****************************************