资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

关于vb.net陈恩点的信息

各位大神帮个忙做个vb.net的程序吧,,,下面是程序要求,一个关于坦克游戏的

陈恩点在此为你解答如有错误请见谅:

创新互联公司是一家专注于成都网站建设、成都网站设计与策划设计,措美网站建设哪家好?创新互联公司做网站,专注于网站建设十载,网设计领域的专业建站公司;建站业务涵盖:措美等地区。措美做网站价格咨询:18980820575

好复杂的 这个编程有一定难度啊

有没有报酬啊

vb.net中listbox内容自动换行如何实现

也不是不可以实现,只不过复杂一点而已,具体看下面代码。不过在需要换行等情况下的文本显示,还是建议用RichTextBox开启只读属性比较省心、比较合适。

Private Sub AutoNextRow()

'获取ListBox行集合文本

Dim length As Integer = (ListBox1.Items.Count - 1)

Dim items(length) As String '行文本数组

For i As Integer = 0 To length

items(i) = ListBox1.Items(i).ToString

Next

'处理ListBox换行

ListBox1.Items.Clear() '清空行内容

Using g As Graphics = Graphics.FromHwnd(ListBox1.Handle)

Dim result As New List(Of Object)

Dim w As Single = ListBox1.ClientSize.Width

Dim sf As SizeF, str As StringBuilder

For Each s As String In items

str = New StringBuilder

For i As Integer = 0 To (s.Length - 1)

sf = g.MeasureString(str.ToString  s(i), ListBox1.Font) 

If sf.Width  w Then

result.Add(str.ToString)

str = New StringBuilder

End If

str.Append(s(i))

If i = s.Length - 1 Then result.Add(str.ToString)

Next

Next

ListBox1.Items.AddRange(result.ToArray) '填充行内容

End Using

End Sub

VS2010用VB语言实现数据库连接,并将表中的数据显示在GridView上。

'================================ACCESS=================================  

Public AccessConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"  _

"Data Source=D:\Simple.mdb;"  _

"Persist Security Info=False" 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Try

Dim AccessString As String = "SELECT * FROM 示例表 "

Dim AccessConn As New OleDb.OleDbConnection(AccessConnectionString)

AccessConn.Open()

Dim AccessAdapter As OleDbDataAdapter = New OleDbDataAdapter(AccessString, AccessConn)

'有返回值

Dim TempDataSet As New DataSet

AccessAdapter.Fill(TempDataSet)

DataGridView1.DataSource = TempDataSet.Tables(0)

AccessConn.Close()

Catch AccessException As Exception

MsgBox(AccessException.Message)

End Try

End Sub

陈恩点原创,转载请保留!

'================================SQL================================

Protected Const SqlConnectionString As String = _

"Server=CED-PC\SQLEXPRESS;"  _

"DataBase=;"  _

"Integrated Security=SSPI"

#Region "Display data"

' Handles the click event for the Display button. This handler gets the product

' information from the Contact table puts it into a DataSet which is used to

' bind to a DataGrid for display. Custom style objects are used to give the 

' DataGrid a nice appearance.

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

If IsNothing(DataGridView1.DataSource) Then

Dim strSQL As String = _

"USE Simple"  vbCrLf  _

"SELECT * "  _

"FROM GetContacts"

Try

' The SqlConnection class allows you to communicate with SQL Server.

' The constructor accepts a connection string as an argument.  This

' connection string uses Integrated Security, which means that you 

' must have a login in SQL Server, or be part of the Administrators

' group for this to work.

Dim dbConnection As New SqlConnection(connectionString)

' A SqlCommand object is used to execute the SQL commands.

Dim cmd As New SqlCommand(strSQL, dbConnection)

' The SqlDataAdapter is responsible for using a SqlCommand object to 

' fill a DataSet.

Dim da As New SqlDataAdapter(cmd)

Dim dsContacts As New DataSet()

da.Fill(dsContacts, "Contact")

With Me.DataGridView1

.Visible = True

.AutoGenerateColumns = False

.AlternatingRowsDefaultCellStyle.BackColor = Color.Lavender

.BackColor = Color.WhiteSmoke

.ForeColor = Color.MidnightBlue

.CellBorderStyle = DataGridViewCellBorderStyle.None

.ColumnHeadersDefaultCellStyle.Font = New Font("Tahoma", 8.0!, FontStyle.Bold)

.ColumnHeadersDefaultCellStyle.BackColor = Color.MidnightBlue

.ColumnHeadersDefaultCellStyle.ForeColor = Color.WhiteSmoke

.DefaultCellStyle.ForeColor = Color.MidnightBlue

.DefaultCellStyle.BackColor = Color.WhiteSmoke

End With

Me.DataGridView1.DataSource = dsContacts.Tables(0)

Dim newColumn As Integer = Me.DataGridView1.Columns.Add("ContactID", "Contact ID")

Me.DataGridView1.Columns(newColumn).DataPropertyName = "ContactID"

newColumn = Me.DataGridView1.Columns.Add("FirstName", "First Name")

Me.DataGridView1.Columns(newColumn).DataPropertyName = "FirstName"

newColumn = Me.DataGridView1.Columns.Add("LastName", "Last Name")

Me.DataGridView1.Columns(newColumn).DataPropertyName = "LastName"

Catch sqlExc As SqlException

MessageBox.Show(sqlExc.ToString, "SQL Exception Error!", _

MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End If

End Sub

#End Region

陈恩点原创,转载请保留!


网站名称:关于vb.net陈恩点的信息
文章分享:http://cdkjz.cn/article/hgjspj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220