站内搜索
广告
Getting Datagrid Columns Keypress,Keyup, Keydown and other events to Fire(一个很好的东西)
作者:    来源:    点击:    日期:2007-7-4 0:52:56   
'It might be easier to read the code if you
'copied this to a text program

'After your form has a functioning datagrid and dataset,
'do the following steps.
'1) Name and declare each column as a textbox as follows

Friend WithEvents Column1 As TextBox
Friend WithEvents Column2 As TextBox

'2) Create the tablestyles.
'Here is the code microsoft gives to do just that.
'(Again I did not write this part; its copied and 'pasted from MS!!)

Private Sub AddTables(ByVal myDataGrid As DataGrid, _
                    ByVal myDataSet As DataSet)
      Dim t As DataTable
      For Each t In myDataSet.Tables
                    Dim myGridTableStyle As DataGridTableStyle = New _
                    DataGridTableStyle()
                    myGridTableStyle.MappingName = t.TableName
                    myDataGrid.TableStyles.Add(myGridTableStyle)
                    ' Note that DataGridColumnStyle objects will
                    ' be created automatically for the first DataGridTableStyle
                    ' when you add it to the GridTableStylesCollection.*/
     Next
End Sub

'3) Add the next line of code in the Form Load Event
      'Use your own variable names for the datagrid and dataset)
      AddTables(DataGrid1, DataSet1)
      'Creates the variable to identify object
      Dim TempColumn As DataGridTextBoxColumn
      'Sets the variable to the datagrid column
Getting Datagrid Columns Keypress,Keyup, Keydown and other events to Fire(一个很好的东西) 评论