Adding a Radio button to a datagrid

  • Thread starter Thread starter Rocky48
  • Start date Start date
R

Rocky48

Guest
I want to add a Radio button to my datagrid, but I am unsure how to do it. Some od the examples I have seen add it to the form load, but I filter the view by using 2 combo boxes.

I assume that I would have to add them to the BtnSearch sub, but most of the examples I have seen add them to a Datagridview and not a datatable as I have.

Once the chosen item is selected I want to use this choice along with some other controls to print a document using FPDF .net.

Any help woul be appreciated.

Here is the code for the form:

Public Class frmSecond
Private connectionString As String = "Data Source=DESKTOP-S7FRNAL\SQLEXPRESS;Initial Catalog=Verses_Find;Integrated Security=True"
Public Property dt As Object

Private Sub frmSecond_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Sub_EventTableAdapter2.Fill(Me.Verses_FindDataSet21.Sub_Event)
Me.Event_TypeTableAdapter1.Fill(Me.Verses_FindDataSet11.Event_Type)
Me.VerseTableAdapter1.Fill(Me.Verses_FindDataSet2.Verse)
DataGridView2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
Me.DataGridView2.DefaultCellStyle.WrapMode = DataGridViewTriState.True
Me.TopMost = True
Me.WindowState = FormWindowState.Maximized


Me.VerseTableAdapter1.Fill(Me.Verses_FindDataSet2.Verse)
Dim sql As String = Nothing
Dim ds As New DataSet()
Dim stepInfo As String = String.Empty
Try
stepInfo = "Step: instatiate connection"
Using connection As New SqlConnection(connectionString)
stepInfo = "Step: test open connection"
connection.Open()
stepInfo = "Step: load first data"
sql = "Select SID, EVENT from Event_Type"
Using adaptor As New SqlDataAdapter(sql, connection)
adaptor.Fill(ds, "Tab_Event_Type")
End Using
stepInfo = "Step: load second data"
sql = "Select BID, SUBEVENT from Sub_Event"
Using adaptor As New SqlDataAdapter(sql, connection)
adaptor.Fill(ds, "Tab_Sub_Event")
End Using
End Using
stepInfo = "Step: bind first combobox"
ComboBox3.DataSource = ds.Tables("Tab_Event_Type")
ComboBox3.ValueMember = "SID"
ComboBox3.DisplayMember = "Event"
stepInfo = "Step: bind second combobox"
ComboBox4.DataSource = ds.Tables("Tab_Sub_Event")
ComboBox4.ValueMember = "BID"
ComboBox4.DisplayMember = "Event_Sub"


Catch ex As Exception
MessageBox.Show($"Error: {stepInfo}{vbNewLine}{ex.ToString}")
End Try
End Sub
Private Sub BtnSearch_Click(sender As Object, e As EventArgs) Handles BtnSearch.Click
Dim sql As String = Nothing
Dim sqlAdapter As SqlDataAdapter
Dim cboVal1 As Integer
Dim cboVal2 As Integer
Dim dt As New DataTable()
cboVal1 = CInt(ComboBox3.SelectedValue)
cboVal2 = CInt(ComboBox4.SelectedValue)

Using connection As New SqlConnection(connectionString)
connection.Open()

Dim selectStatement = $"Select Verse From Verse where Event= {cboVal1} and Event_Sub= {cboVal2}"
sqlAdapter = New SqlDataAdapter(selectStatement, connection)
dt = New DataTable()
sqlAdapter.Fill(dt)
DataGridView2.DataSource = dt

Dim rowCount = 0
rowCount = dt.Rows.Count
TextBox1.Text = rowCount
End Using
End Sub

Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Close()
End Sub
End Class




TEH

Continue reading...
 
Back
Top