VS 2015 - C#我是C中的新蜜蜂#需要有关listview的帮助 [英] VS 2015 - C# I am a new bee in C# Need help with a listview
问题描述
以下是我在 VB语言中的代码,用于创建表格并显示列表视图。 我需要在
C#语言中使用VS 2015时如何做同样的示例。 请将我发送到可以帮助我解决此问题的正确论坛。 VB代码如下:
The following is my code in VB language to create a table and display a listview. I need samples on how to do the same in using VS 2015 in the C# language. Please sent me to the correct forum that can help me with this problem. The VB code is below:
' Add Columns
OutstandingTable.Columns.AddRange(New DataColumn() {New DataColumn("ddate", GetType(String)),
New DataColumn("ddesc", GetType(String)),
New DataColumn("ddebit", GetType(String)),
New DataColumn("dincome", GetType(String)),
New DataColumn("dmeth", GetType(String)),
New DataColumn("dcate", GetType(String)),
New DataColumn("dstatus", GetType(String)),
New DataColumn("dtype", GetType(String)),
New DataColumn("dcomm", GetType(String))})
Dim connectionString As String =
"data source=SQL5007.myWindowsHosting.com;initial catalog=DB_9AC0D3_edbenoit;user id=DB_9AC0D3_edbenoit_admin;password=cale1111"
Dim connection As New SqlConnection()
connection.ConnectionString = connectionString
Dim SelectStatement As String =
"SELECT ymon, dyear, ddate, ddesc, ddebit, dincome, dmeth, dcate, dstatus, dtype, dcomm " &
"FROM DBO.SS_" & issn & "_BUDGET_TABLE WHERE ymon = @ymon and dstatus = @dstatus order by ddate desc, ddesc asc, dtype asc"
Dim selectcommand As New SqlCommand(SelectStatement, connection)
selectcommand.Parameters.AddWithValue("@ymon", ymon)
selectcommand.Parameters.AddWithValue("@dstatus", dstatus)
Try
connection.Open()
'Dim reader As SqlDataReader = selectcommand.ExecuteReader(CommandBehavior.SingleRow)
Dim reader As SqlDataReader = selectcommand.ExecuteReader()
Do While reader.Read
dyear = reader("dyear").ToString.Trim
ddate = reader("ddate").ToString.Trim
ddesc = reader("ddesc").ToString.Trim
ddebit = reader("ddebit").ToString.Trim
dincome = reader("dincome").ToString.Trim
dmeth = reader("dmeth").ToString.Trim
dcate = reader("dcate").ToString.Trim
dstatus = reader("dstatus").ToString.Trim
dtype = reader("dtype").ToString.Trim
dcomm = reader("dcomm").ToString.Trim
add_my_entry() '<======== NOTE Add this entry to the listview and return
Loop
Catch ex As SqlException
'Throw ex
'MessageBox.Show("Error on SELECT " & ex.Message, ex.GetType.ToString)
lblmessage.Text = "Error on Select " & ex.Message & ex.GetType.ToString
Finally
connection.Close()
End Try
Private Sub Add_My_Entry()
OutstandingTable.Rows.Add(ddate, ddesc, ddebit, dincome, dmeth, dcate, dstatus, dtype, dcomm)
ListView_Budget.DataSource = OutstandingTable
ListView_Budget.DataBind()
End Sub
Edcal
推荐答案
以下是我的代码 VB语言创建表格并显示列表视图。 我需要在
C#语言中使用VS 2015时如何做同样的示例。 请将我发送到可以帮助我解决此问题的正确论坛。 VB代码如下:
The following is my code in VB language to create a table and display a listview. I need samples on how to do the same in using VS 2015 in the C# language. Please sent me to the correct forum that can help me with this problem. The VB code is below:
这篇关于VS 2015 - C#我是C中的新蜜蜂#需要有关listview的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!