| Author: Ashokkumar 19 Jul 2008 | Member Level: Gold | Rating: Points: 5 |
hi this code in VB.net to convert C# Dim OleCB2 As New OleDbCommandBuilder(daSubCategory) daSubCategory.Fill(dsSubCategory)
CType(dgvAlert.Columns(1), DataGridViewComboBoxColumn).DataSource = dsCategory.Tables(0) CType(dgvAlert.Columns(1), DataGridViewComboBoxColumn).DisplayMember = "CT_Description" CType(dgvAlert.Columns(1), DataGridViewComboBoxColumn).ValueMember = "CT_Code"
|
| Author: chandramohan 19 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
Imports System.Data Imports System.Data.SqlClient
PublicClass frmCboBoxTest
'Declare Object and Database Connection String Dim objConnection AsNew SqlConnection _ ("server=OFFSITE-223181S\SQLEXPRESS;database=TemDb;Trusted_Connection=yes;")
'SELECT statement for the ComboBox Dim objDataAdapter2 AsNew SqlDataAdapter( _ "SELECT Satellite.SatelliteSccNum4 From Satellite", objConnection)
'SELECT statement for DataGridView And 'JOIN WHERE Signal Table Transponder ID is Equal to Transponder Table Transponder ID Dim objDataAdapter AsNew SqlDataAdapter( _ "SELECT * FROM Signal, objConnection)
'ComboBox1 connection Information Dim objDataSet2 As DataSet Dim objDataView2 As DataView
'DataGrid connection information Dim objDataSet As DataSet Dim objDataView As DataView
PrivateSub FillDataSetAndView()
'ComboBox1 objDataSet2 = New DataSet objDataView2 = New DataView(objDataSet2.Tables("Satellite"))
'DataGridView objDataSet = New DataSet objDataView = New DataView(objDataSet.Tables("Signal"))
'Fill the ComboBox with data objDataAdapter2.Fill(objDataSet2, "Satellite")
'Fill the DataGrid with data objDataAdapter.Fill(objDataSet, "Signal")
EndSub
PrivateSub BindFields()
'Clear any previous bindings ComboBox1.DataBindings.Clear() grdCboTest.DataBindings.Clear()
'Set the ComboBox properties to bind it to the data and 'Add Satellite SCC #s' from the Satellite DB ComboBox1.DataSource = objDataSet2.Tables("Satellite") ComboBox1.DisplayMember = "SatelliteSccNum4" ComboBox1.ValueMember = "SatelliteSccNum4"
EndSub
PrivateSub ComboBox1_SelectedIndexChanged( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex Then
'Open the database connection objConnection.Open()
'Set the DataGridView properties to bind it to the data grdCboTest.AutoGenerateColumns = True grdCboTest.DataSource = objDataSet grdCboTest.DataMember = "Signal"
'Close the Database connection objConnection.Close()
'Fill the dataset and bind the fields FillDataSetAndView() BindFields()
EndIf
EndSub
PrivateSub frmCboBoxTest_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load
'Fill ComboBox and DataGridView with data from DB at Load FillDataSetAndView() BindFields()
'Set ComboBox Selected index to the 1st position or 0 index at Load ComboBox1.SelectedIndex = 0
EndSub
PrivateSub btnExit_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
'Close application when btnExit is Clicked Me.Close()
EndSub
EndClass
|