日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
代碼講述VB.NET實現(xiàn)數(shù)據(jù)綁定

VB.NET還是比較常用的,于是我研究了一下VB.NET實現(xiàn)數(shù)據(jù)綁定,在這里拿出來和大家分享一下,希望對大家有用。以下介紹VB.NET實現(xiàn)數(shù)據(jù)綁定:

TextBox組件通過下列語句就可以把已經(jīng)得到的數(shù)據(jù)集"myDataSet"中的"books.bookid"字段值綁定到TextBox1的"Text"屬性上:TextBox1.DataBindings.Add ( New Binding ( "Text" , Me.myDataSet , "books.bookid" ) ) 了解了這二點,就不難實現(xiàn)對TextBox組件的數(shù)據(jù)綁定了。下面是VB.NET實現(xiàn)數(shù)據(jù)綁定的源程序代碼:

 
 
 
  1. Imports System.Drawing  
  2. Imports System.Windows.Forms  
  3. Imports System.ComponentModel  
  4. Imports System  
  5. Imports System.Data.OleDb  
  6. Imports System.Data  
  7.  
  8. Public Class Form1  
  9. Inherits Form  
  10.  
  11. Private WithEvents Button1 As Button  
  12. Private TextBox1 As TextBox  
  13. Private myDataSet As DataSet  
  14. Private components As System.ComponentModel.Container  
  15.  
  16. Public Sub New ( )  
  17. MyBase.New()  
  18. GetConnected ( )  
  19. InitializeComponent ( )  
  20. End Sub  
  21. '清除在程序中使用過的資源  
  22. Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )  
  23. If disposing Then  
  24. If Not ( components Is Nothing ) Then  
  25. components.Dispose ( )  
  26. End If  
  27. End If  
  28. MyBase.Dispose ( disposing )  
  29. End Sub  
  30. '打開數(shù)據(jù)表,返回數(shù)據(jù)集  
  31. public Sub GetConnected ( )  
  32. '創(chuàng)建一個 OleDbConnection  
  33. Dim strCon As String = " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = ..\sample.mdb" 
  34. Dim myConn As OleDbConnection = new OleDbConnection ( )  
  35. myConn.ConnectionString = strCon 
  36.  
  37. Dim strCom As string = " SELECT * FROM books " 
  38. '創(chuàng)建一個 DataSet  
  39. myDataSet = new DataSet( )  
  40.  
  41. myConn.Open ( )  
  42. '用 OleDbDataAdapter 得到一個數(shù)據(jù)集  
  43. Dim myCommand As OleDbDataAdapter = new OleDbDataAdapter ( strCom , myConn )  
  44. '把Dataset綁定books數(shù)據(jù)表  
  45. myCommand.Fill ( myDataSet , "books" )  
  46. '關(guān)閉此OleDbConnection  
  47. myConn.Close ( )  
  48.  
  49. End Sub  
  50. '初始化窗體中的組件  
  51. Private Sub InitializeComponent ( )  
  52. Me.Text = "對TextBox組件實現(xiàn)數(shù)據(jù)綁定!" 
  53. Me.Width = 400 
  54. Me.Height = 300 
  55.  
  56. Button1 = New Button ( )  
  57. TextBox1 = New TextBox ( )  
  58.  
  59. Button1.Left = 200 
  60. Button1.Top = 200 
  61. Button1.Width = 100 
  62. Button1.Height = 40 
  63. Button1.TabIndex = 0 
  64. Button1.Text = "數(shù)據(jù)綁定" 
  65.  
  66. TextBox1.Left = 200 
  67. TextBox1.Top = 30 
  68. TextBox1.Width = 150 
  69. TextBox1.Height = 40 
  70.  
  71. Me.Controls.Add ( Button1 )  
  72. Me.Controls.Add ( TextBox1 )  
  73.  
  74. End Sub  
  75.  
  76. Private Sub Button1_Click ( ByVal sender As Object , _  
  77. ByVal e As System.EventArgs ) Handles Button1.Click  
  78. TextBox1.DataBindings.Add ( New Binding ( "Text" , Me.myDataSet , "books.bookid" ) )  
  79. End Sub  
  80. End Class  
  81.  
  82. Module Module1  
  83. Sub Main ( )  
  84. Application.Run ( new Form1 ( ) )  
  85. End sub  
  86. End Module 

文章名稱:代碼講述VB.NET實現(xiàn)數(shù)據(jù)綁定
標題URL:http://m.5511xx.com/article/cochpgp.html