zoukankan      html  css  js  c++  java
  • Combobox代码

    不可编辑代码:

    ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList

     

    动态添加代码:

     

    写在前面的语句:

    Imports System.Data

    Imports System.Data.OleDb

    ――――――――――――――――

    连接语句:

    Private ds1 As DataSet = New DataSet

    Private strcon As String = "Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=storehouse;User ID=sa;Password=sa"

    Public DBcon As New OleDbConnection(strcon)

    ―――――――――――――――――

    DBcon.Open()

    Dim sqlStr As String = "SELECT 动态添加的列 FROM 动态添加的表"

    Dim adt As New OleDbDataAdapter(sqlStr, DBcon)

    ds1.Clear()

       adt.Fill(ds1)

       DBcon.Close()

       ComboBox1.Items.Clear()

       Dim count As Integer = ds1.Tables(0).Rows.Count

       For i As Integer = 0 To count - 1

          ComboBox1.Items.Add(CStr(ds1.Tables(0).Rows(i).Item("动态添加的列")))

       Next i

    ――――――――――――――――――

  • 相关阅读:
    QT下载速度慢的解决方法
    第七章 多态
    第六章 重复运用class
    第五章 隐藏实现细节
    代码改变世界
    第四章 初始化和清理
    第三章 控制程序流程
    module.exports和exports
    如何与外部源交互
    实现POST服务器
  • 原文地址:https://www.cnblogs.com/sishierfei/p/1610386.html
Copyright © 2011-2022 走看看