我目前在使用Windows窗體應用程序的VB.net express 2013。我有一個面板上有84個按鈕,每個按鈕代表一個物理單元。當按下按鈕時,我彈出一個對話框來顯示該單元格的內容。但是,我不知道如何讓代碼拉取該按鈕的名稱,並將其放入where部分的sql語句中。我的按鈕是名爲cmdM01,cmdM02, cmdM03 ....等的設計。等等.Sql名稱是M01,M02,M03等等。 *請注意,我現在正在使用1 = @shear進行測試。我需要弄清楚如何取代那個能識別細胞的東西。 這是到目前爲止我的代碼:如何選擇什麼按鈕正在點擊一個多按鈕點擊事件,由sql支持
Public Sub Button_Click(ByVal o As Object, ByVal e As EventArgs) Handles cmdM01.Click, cmdM02.Click, cmdM03.Click, cmdM04.Click, cmdM05.Click, cmdM06.Click, cmdM07.Click,
cmdM08.Click, cmdM09.Click, cmdM10.Click, cmdM11.Click, cmdM12.Click, cmdT01.Click, cmdT02.Click, cmdT03.Click, cmdT04.Click, cmdT05.Click, cmdT06.Click, cmdT07.Click, cmdT08.Click,
cmdT09.Click, cmdT10.Click, cmdT11.Click, cmdT12.Click, cmdT13.Click, cmdT14.Click, cmdT15.Click, cmdT16.Click, cmdT17.Click, cmdT18.Click, cmdT19.Click, cmdT20.Click,
cmdT21.Click, cmdT22.Click, cmdT23.Click, cmdT24.Click, cmdH01.Click, cmdH02.Click, cmdH03.Click, cmdH04.Click, cmdH05.Click, cmdH06.Click, cmdH07.Click, cmdH08.Click, cmdH09.Click,
cmdH10.Click, cmdH11.Click, cmdH12.Click, cmdH13.Click, cmdH14.Click, cmdH15.Click, cmdH16.Click, cmdH17.Click, cmdH18.Click, cmdH19.Click, cmdH20.Click, cmdH21.Click,
cmdH22.Click, cmdH23.Click, cmdH24.Click, cmdP01.Click, cmdP02.Click, cmdP03.Click, cmdP04.Click, cmdP05.Click, cmdP06.Click, cmdP07.Click, cmdP08.Click, cmdP09.Click, cmdP10.Click,
cmdP11.Click, cmdP12.Click, cmdP13.Click, cmdP14.Click, cmdP15.Click, cmdP16.Click, cmdP17.Click, cmdP18.Click, cmdP19.Click, cmdP20.Click, cmdP21.Click, cmdP22.Click, cmdP23.Click, cmdP24.Click
'load selection for all buttons
Using conn1 As New SqlConnection(connstring)
conn1.Open()
Using comm1 As New SqlCommand("SELECT Shear FROM Production.dbo.tblFabWipLog WHERE FabWipID = @Cell", conn1)
comm1.Parameters.AddWithValue("@Cell", 1)
Dim sql As New SqlDataAdapter(comm1)
Dim dt As New DataTable
sql.Fill(dt)
Dim f As New CellContent
f.LabelShear.Text = dt.Rows(0)("Shear").ToString
f.ShowDialog()
End Using
End Using
End Sub
天才,我可以找出我自己的選擇案例。你真棒。 – Cheddar 2014-11-21 14:25:01