❶ vb 展開combo列表的方法
補充一下,需要先獲得焦點:
PrivateSubCommand1_Click()
Combo1.SetFocus'獲取焦點
SendKeys"%{Down}"'發送虛擬鍵ALT+下
EndSub
❷ vb中combo的詳細用法
1、定義控制項對應變數
假定已經創建了一個Dialog,並且從控制項工具箱將 Combo Box 控制項拖放到上面。打開 Class Wizard,添加控制項對應變數,如:CComboBoxm_cbExamble;
在後面的代碼中會不斷使用這個變數。
2、在ComboBox控制項屬性的Data標簽裡面添加,一行表示ComboBox下拉列表中的一行。換行用ctrl+回車。
3、在程序初始化時動態添加
如: //控制項內容初始化
CString strTemp;
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->ResetContent();//消除現有所有內容
for(int i=1;i<=100;i++)
{
strTemp.Format("%d",i);
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->AddString(strTemp);
}
4、下拉的時候添加
如:CString strTemp;
intiCount=((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetCount();//取得目前已經有的行數
if(iCount<1)//防止重復多次添加
{
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->ResetContent();
for(inti=1;i<=100;i++)
{
strTemp.Format("%d",i);
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->AddString(strTemp);
}
}
5、取得Combo Box框內容
取當前內容
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetWindowText(strTemp);
取其他行內容
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetLBText(n,strTemp);
❸ VB解決,獲得正在運行程序的combobox當前內容
當組合框改變時獲取內容:
Private Sub Combo1_Click()
Text1 = Combo1.Text
End Sub
當單擊按鈕時獲取組合回框內容答:
Private Sub Command1_Click()
Text1 = Combo1.Text
End Sub
❹ VB,如何使用combo作為選擇
Private Sub Combo1_Click()
Text1 = Combo1 + 1
Text2 = Combo1 + 2
Text3 = Combo1 + 3
Text4 = Combo1 + 4
Text5 = Combo1 + 5
Text6 = Combo1 + 6
Text7 = Combo1 + 7
End Sub
要刪除的話
用Combo1.RemoveItem 0 後面的0代表的是刪除第一項 要刪除第二版項就Combo1.RemoveItem 1 依次類推權
如果要刪除選中的 用Combo1.RemoveItem Combo1.ListIndex 就可以了
❺ VB按鈕控制combo
Private Sub Command1_Click()
If Combo1.Text = "A" Then
Combo2.Clear
Combo2.AddItem "A1"
Combo2.AddItem "A2"
Combo2.AddItem "A3"
End If
If Combo1.Text = "B" Then
Combo2.Clear
Combo2.AddItem "B1"
Combo2.AddItem "B2"
Combo2.AddItem "B3"
End If
If Combo1.Text = "C" Then
Combo2.Clear
Combo2.AddItem "C1"
Combo2.AddItem "C2"
Combo2.AddItem "C3"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"
Combo1.AddItem "C"
End Sub
❻ VB如何獲取外部程序的combobox的內容
很難很難,沒有外部程序的源碼,很難實現,combobox是組合框,還有很多內容未顯示出來的,顯示出來的內容可以考慮用屏幕捕捉來獲取
❼ vb獲得外部程序的combobox內容
Option Explicit
Private Const CB_GETCOUNT = &H146
Private Const CB_GETLBTEXT = &H148
Private Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Private Sub Command1_Click()
Dim count As Long
Dim a As String
a = String$(255, 0)
count = SendMessageBynum&(Combohwnd, CB_GETCOUNT, 0, 0)
SendMessageByString& Combohwnd, CB_GETLBTEXT, 0, a
a = Left$(a, InStr(a, Chr$(0)) - 1)
End Sub
Combohwnd 是 combobox 的句柄
count 是獲取的 combobox 項目數
a 是獲取的 combobox 指定項內容, 0 對應第一項
❽ vb控制項combo1使用方法
一:新建一個模塊,保存以下代碼.注意修改資料庫路徑/名/密碼/
Public Conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public Sql As String
Public UserName As String
Public UserLimit As Integer
'==================
'連接資料庫
'==================
Public Function DB_Link()
On Error Resume Next
Dim CnStr As String
Dim DBPath As String, DBName As String
Dim DBUser As String, DBPsw As String
DBPath = App.Path & "\" '資料庫地址
DBName = DATABASE_NAME '資料庫文件名
DBPsw = DATABASE_PASSword '資料庫密碼
CnStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data source =" & DBPath & DBName & "; Jet OLEDB:Database Password=" & DBPsw
Conn.CursorLocation = adUseClient '必須設置客戶端游標方式
Conn.Open CnStr
End Function
'====================
'斷開資料庫
'====================
Public Function DB_Close()
On Error Resume Next
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
End Function
二:窗體代碼.
private sub form_load()
db_link
sql = "select * from 保存項目名稱的那個表名"
set rs =conn.execute(sql)
do until rs.eof
combo1.additem rs("項目名稱所在列名")
rs.movenext
db_close
end sub
以上是添加到combo1的代碼...
後面你說的什麼保存到用戶信息表中什麼的看不明白..
需要幫忙的話給我發email:[email protected]
❾ vb程序編程,就是combo下拉菜單中,那些選項的排列是怎麼樣的
Combo1.List(0) = "梨子" 這句是設置列表第一個項目的內容 也就是 西瓜被替換成梨子了
順序沒錯
Combo1.AddItem "西瓜"
Combo1.AddItem "蘋果"
Combo1.AddItem "橘子"
Combo1.AddItem "葡萄"
Combo1.AddItem "哈密瓜"
Combo1.AddItem "火龍果"
Combo1.AddItem "柚子"
Combo1.List(0) = "梨子"
Combo1.List(7) = "獼猴桃"
❿ VB 中用按鈕控制 combo 的方法
Private Sub Command1_Click()
Dim index As Integer
index = Combo1.ListIndex
If index = Combo1.ListCount - 1 Then
MsgBox ("沒有內容")
Exit Sub
End If
Combo1.ListIndex = index + 1
End Sub