在框架V1.1中对BindingContext进行BUG [英] BUG on BindingContext in framework V1.1

查看:54
本文介绍了在框架V1.1中对BindingContext进行BUG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我一直试图从法国新闻组得到答案,但我确实没有成功

,所以我试试这个小组,抱歉我的英语很差。


错误描述:


来自BindinManager的CurrentChanged事件在Winform上永远不会发生带有框架V1.1的
。并且不可能从绑定中知道用户是否进行了一些修改




使用框架V1.0就可以了


您可以在样本后找到重现此错误的内容。你只需要第一次使用框架1.0来玩

,看看如果你改变了

中的任何内容你得到了一个消息框。

如果你在你的项目中将框架设置为V1.1并进行播放,你会发现

该框架没有引发该事件。

该项目由一个简单的表单(form1)和2个文本框组成,用于显示

数据。它运行在Pubs数据库上,运行在本地的SQL Server上。


我想知道微软团队是否知道这个bug,如果一个补丁是

是为了这个还是有计划的?


谢谢,

Sebastien

''********* ******代码表格FORM1

******************************** ****************** **

Imports System.Data

Imports System.Data.SqlClient


公共类Form1

继承System.Windows.Forms.Form

#Region" Codegénéréparle Concepteur Windows Form"

Public Sub New()

MyBase.New()

''Cet appel est requis par le Concepteur Windows Form。

InitializeComponent()

''Ajoutez une initialisationquelconqueaprèsl''appel InitializeComponent()

End Sub

''Laméthode替代品Dispose du formulaire pour nettoyer la liste des

composants。

受保护的重载覆盖Sub Dispose(ByVal disposing As Boolean)

如果处置那么

如果不是(组件什么都没有)那么

components.Dispose()

结束如果

结束如果

MyBase.Dispose(处置)

End Sub

''Requis par le Concepteur Windows Form

私有组件As System.ComponentModel.IContainer

''REMARQUE:laprocédureuivanteest requise par le Concepteur Windows Form

''Ellepeutêtremodifiée en utilisant le Concepte你的Windows窗体。

''Ne la modifiez pas en utilisant l''éditeurdecode。

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)处理MyBindingManager.CurrentChanged

MsgBox(Modificationdesdonnées)

End Sub

Private Sub Form1_Load(ByVal sender As Object,ByVal e As System.EventArgs)

处理MyBase.Load

将CNX作为字符串调暗

Dim ds作为数据集

CNX =" Integrated Security = SSPI; Initial Catalog = Pubs; Data Source = 127.0.0.1"

ds = ExecuteSQL(选择前10名来自作者,CNX,真)

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

公共函数Exec​​uteSQL(ByVal sSql As String,ByVal ConnectionString As

String,可选ByVal TimeOut As Integer = 30,可选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

试试

Conn = New SqlConnection(ConnectionString)

selectCMD = New SqlCommand(sSql,Conn)

selectCMD.CommandTimeout = TimeOut

da = New SqlDataAdapter

da.SelectCommand = selectCMD

Conn.Open()

ds =新数据集

da.Fill( ds,ROWSET)

Conn.Close()

Catch

如果DisplayErrorMessages = True然后

调用MsgBox(" Err:" &安培; Err.Number& vbCrLf& 描述: &

Err.Description,MsgBoxStyle.Critical,Erreur d'accancesdonnées)

结束如果

结束尝试

返回ds

结束功能

结束班级

''*********** ****表格1的结尾

********************************* ********

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
*****************************************


推荐答案

尝试使用CurrencyManager而不是BindingManagerBase ...


我不知道它是否可行,但我之前已经有了火上浇油

currencymanager 1.1之前


- CJ


" ABC - SébastienBeaugrand" <是******* @ activebaseconcept.com>写在

消息新闻:40 *********************** @ news.free.fr ...
Try using a CurrencyManager instead of BindingManagerBase...

I have no clue if it would work, but I have had currentchanged fire on
currencymanager before in 1.1

-CJ

"ABC - Sébastien Beaugrand" <be*******@activebaseconcept.com> wrote in
message news:40***********************@news.free.fr...


我一直试图从法国新闻组得到一个答案,但我确实没有
成功,所以我会尝试这个组抱歉我的英文不好。

错误描述:

Winform上BindinManager的CurrentChanged事件永远不会发生在框架V1.1上。并且不可能从绑定中知道用户是否做了一些修改。

使用框架V1.0就可以了。

你可以找到重现此错误的示例。你只需要第一次使用框架1.0来玩这个,看看如果你在表单中更改了任何内容,你就会得到一个消息框。

如果你将框架设置为V1 .1在你的项目中播放它,你会发现框架没有引发事件。
该项目由一个简单的表单(form1)和2个文本框组成,价格为
显示数据。它是在本地运行的SQL Server上的Pubs数据库上运行的。

我想知道微软团队是否知道这个错误,是否存在
补丁或计划?

谢谢你,
Sebastien

''***************代码表格FORM1
** ************************************************ **
Imports System.Data
Imports System.Data.SqlClient

公共类Form1
继承System.Windows.Forms.Form
#Region" Codegénéréparle Concepteur Windows Form
Public Sub New()
MyBase.New()
''Cet appel est requis par le Concepteur Windows Form。
InitializeComponent()
''Ajoutez初始化quelconqueaprèsl''appel InitializeComponent()
End Sub
''Laméthode替代品Dispose du formulaire pour nettoyer la liste des
composants。
受保护的重载覆盖子处理(ByVal处理为布尔值)
如果处理则
如果不是(组件什么都没有)那么
components.Dispose()
结束如果
结束如果
MyBase.Dispose(处理)
End Sub
''Requis par le Concepteur Windows Form
私有组件As System.ComponentModel.IContainer
''REMARQUE: laprocédureuivanteest requise par le Concepteur Windows
Form''Ellepeutêtremodifiéeenutilisant le Concepteur Windows Form。
''Ne la modifiez pas en utilisant l''éditeurdecode。
朋友Wi thEvents 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
''
我。 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 Wit hEvents MyBindingManager As BindingManagerBase
Dim ds As New DataSet
Dim dt As New DataTable
Private Sub MyBindingManager_CurrentChanged(ByVal sender As Object,ByVal $ b $ as As System.EventArgs)Handles MyBindingManager.CurrentChanged < MsgBox(Modificationdesdonnées)
End Sub
Private Sub Form1_Load(ByVal sender As Object,ByVal e As
System.EventArgs)处理MyBase.Load
将CNX调暗为字符串
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()
我。 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
公共函数Exec​​uteSQL(ByVal sSql As String,ByVal ConnectionString As
String,可选ByVal TimeOut As Integer = 30,可选ByVal
DisplayErrorMessages As Boolean = False)As Data.DataSet
Dim Conn As SqlConnection
Dim selectCMD As SqlCommand
Dim da As SqlDataAdapter
Dim ds作为Data.DataSet
尝试
Conn =新的SqlConnection(ConnectionString)
selectCMD =新的SqlCommand(sSql,Conn)
selectCMD.CommandTimeout = TimeOut
da = New SqlDataAdapter
da.SelectCommand = selectCMD
Conn.Open()
ds =新数据集
da.Fill (ds,ROWSET)
Conn.Close()
Catch
如果DisplayErrorMessages = True那么
调用MsgBox(" Err:" &安培; Err.Number& vbCrLf& 描述: &
Err.Description,MsgBoxStyle.Critical,Erreur d'accancesdonnées)
结束如果
结束尝试
返回ds
结束功能<结束课程
''***************表格1的终止
*************** ************************** *
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
*****************************************



你好SébastienBeaugrand


我对它进行了测试,如果位置发生变化,我会发火。


我是荷兰人,所以也不是母语人士有些人肯定会告诉我们

当这个事件发生时应该如何解读这个描述。

http://msdn.microsoft.com/library/de .. .angedtopic.asp


Cor
Hi Sébastien Beaugrand

I tested it and if fires for me when the position changes.

I am Dutch so also not a native speaker, however some here will sure tell us
how to read when this event should fire as meant by this description.

http://msdn.microsoft.com/library/de...angedtopic.asp

Cor


我试过一个CurrencyManager但结果是一样的。


谢谢


" CJ Taylor" < [cege] at [tavayn] dit commmmm>一个écritdansle message de

新闻:O9 ************** @ tk2msftngp13.phx.gbl ...
I Tried a CurrencyManager but the result is the same.

Thanks

"CJ Taylor" <[cege] at [tavayn] dit commmmm> a écrit dans le message de
news:O9**************@tk2msftngp13.phx.gbl...
尝试使用一个CurrencyManager而不是BindingManagerBase ...

我不知道它是否会起作用,但我在1.1之前已经有了火上浇油的事情。

-CJ

ABC - SébastienBeaugrand <是******* @ activebaseconcept.com>在
消息新闻中写道:40 *********************** @ news.free.fr ...
Try using a CurrencyManager instead of BindingManagerBase...

I have no clue if it would work, but I have had currentchanged fire on
currencymanager before in 1.1

-CJ

"ABC - Sébastien Beaugrand" <be*******@activebaseconcept.com> wrote in
message news:40***********************@news.free.fr...


我一直试图从法国新闻组得到答案,但我没有成功
Hi,

I''ve been trying to get an answer from french newsgroup but I did''nt succeed
,所以我会尝试这个组抱歉我的英文不好。

错误的描述:

Winform上BindinManager的CurrentChanged事件从不会出现
,框架V1.1。如果用户做了一些修改,就不可能从绑定中知道


使用框架V1.0就可以了。

你可以找到重现此错误的示例。你只需要第一次使用framework 1.0来玩这个,看看如果你在表单中更改任何
,你就会得到一个消息框。

如果你将框架设置为V1 .1在你的项目中播放它,你会
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


注意

该框架不会引发事件。
该项目由一个简单形式(form1),带有2个文本框
that the event is not raised by the framework.
The project is made of a simple form (form1) with 2 textbox for


displayiong


displayiong

data。它运行在本地运行的SQL Server的Pubs数据库上。

我想知道微软团队是否知道这个bug,并且
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


Patch

是为此而存在还是有计划的?

谢谢你,
Sebastien

''************* **代码表格表格1
**************************************** ********** **
Imports System.Data
Imports System.Data.SqlClient

公共类Form1
继承System.Windows。 Forms.Form
#Region" Codegénéréparle Concepteur Windows Form
Public Sub New()
MyBase.New()
''Cet appel est requis par le Concepteur Windows Form。
InitializeComponent()
''Ajoutez初始化quelconqueaprèsl''appel
InitializeComponent()End Sub
''Laméthode替代品Dispose du formulaire pour nettoyer la liste des
composants。
受保护的重载覆盖子处理(ByVal处理为布尔值)
如果处理则
如果不是(组件什么都没有)那么
components.Dispose()
结束如果
结束如果
MyBase.Dispose(处理)
End Sub
''Requis par le Concepteur Windows Form
私有组件As System.ComponentModel.IContainer
''REMARQUE: laprocédureuivanteest requise par le Concepteur Windows
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


表格

''Ellepeutêtremodifiéeenutilisant le Concepteur Windows Form。
''Ne la modifiez pas en utili sant l''éditeurdecode。
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
< System.Diagnostics.DebuggerStepThrough( )> Private Sub
''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()


InitializeComponent()

Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox < br。> 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作为Object,
ByVal e
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)处理MyBindingManager.CurrentChanged
MsgBox(Modificationdesdonnées)
End Sub
Private Sub Form1_Load(ByVal sender As Object,ByVal e As
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)


System.EventArgs)

Handles MyBase.Load
Dim CNX As String
Dim ds As DataSet
CNX =" Integrated Security = SSPI; Initial Catalog = Pubs; Data
Handles MyBase.Load
Dim CNX As String
Dim ds As DataSet
CNX = "Integrated Security=SSPI;Initial Catalog=Pubs;Data


Source = 127.0.0.1"


Source=127.0.0.1"

ds = ExecuteSQL(" select来自作者的前10 *,CNX,,True)
dt = ds.Tables(0)
Me.TextBox1.DataBindings.Clear()
Me.TextBox1.DataBindings.Add(" ; Text",dt," au_fname")
Me.TextBox2.DataBindings.Clear()
M e.TextBox2.DataBindings.Add(" Text",dt," au_lname")
MyBindingManager = Me.BindingContext.Item(dt)
End Sub
公共函数Exec​​uteSQL(ByVal sSql As String,ByVal ConnectionString
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,可选ByVal TimeOut As Integer = 30,可选ByVal
DisplayErrorMessages As Boolean = False)As Data.DataSet
Dim selectCMD As SqlCommand
Dim da As SqlDataAdapter
Dim ds As Data.DataSet
尝试
Conn = New SqlConnection(ConnectionString)
selectCMD = New SqlCommand(sSql,conn)
selectCMD.CommandTimeout = TimeOut
da = New SqlDataAdapter
da.SelectCommand = selectCMD
Conn.Open()
ds =新数据集
da.Fill(ds," ROWSET")
Conn.Close()
Catch
如果DisplayErrorMessages = True那么
调用MsgBox(& ;呃: &安培; Err.Number& vbCrLf& 描述: &
Err.Description,MsgBoxStyle.Critical,Erreur d'accancesdonnées)
结束如果
结束尝试
返回ds
结束功能<结束课程
''***************表格1的终止
*************** **************************


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
*****************************************




这篇关于在框架V1.1中对BindingContext进行BUG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆