找回密码
 加入
搜索
查看: 2010|回复: 9

有关选择框(ComboBox)控件输入的问题????

[复制链接]
发表于 2009-1-28 13:12:26 | 显示全部楼层 |阅读模式
我想限制选择框(ComboBox)控件输入字符数量,查了好写资料帮助信息都找不到怎么解决,希望各位大虾能给指条名路,不盛感激!!

[ 本帖最后由 gaofali258 于 2009-1-29 11:41 编辑 ]
发表于 2009-1-28 13:35:16 | 显示全部楼层
输入框可以,InputBox

选择框就不知道了!
 楼主| 发表于 2009-1-28 13:41:08 | 显示全部楼层
输入框我也知道可以啊`~!~可就这个弄的我是没办法`!~
发表于 2009-1-28 15:16:15 | 显示全部楼层
[au3]#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 449, 193, 125)
$Combo1 = GUICtrlCreateCombo("Combo1", 208, 80, 153, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        If stringLen(GUICtrlRead($Combo1)) > 3 Then
                GUICtrlSetData($Combo1,StringLeft(GUICtrlRead($Combo1),3))
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd[/au3]
写了个简单的。。。。
 楼主| 发表于 2009-1-28 15:55:24 | 显示全部楼层
老兄!你的这个办法我用过的,这个办法有弊端,就是一旦超过字符数就把里面的数据用后来的更新了,我的目的就是让他输入到一定字符就是不能输入只能改动~
发表于 2009-1-28 18:21:59 | 显示全部楼层
汗 我想说的是.....谁用combo来输入...... combo用来被选择才是最好的用处吧

如果你要输入的话 换input不好么
发表于 2009-1-28 20:13:00 | 显示全部楼层
#include <GuiComboBox.Au3>
$hGui = GuiCreate('combo', 300, 200)

$combo = GuiCtrlCreateCombo('a', 5, 5, 290, 100)
GuiCtrlSetData(-1, "b|c|d", "b")

$dmy = GuiCtrlCreateButton('', 50, 50, 70, 20)
GuiCtrlSetState(-1, 32)

GuiSetState()
GuiRegisterMsg(0x111, "_wmCommand")

Do
        $msg = GuiGetMsg()
Until        $msg = -3

Func _wmCommand($hWnd, $message, $wParam, $sParam)
        Local $notifyCode = BitShift($wParam, 16)
        Local $Id = BitAnd($wParam, 0xffff)
        If $Id = $Combo And $notifyCode = $cbn_editChange then
                $text = GuiCtrlRead($Id)
                If stringLen($text) > 5 then
                        _GuiCtrlComboBox_SetEditText($combo, stringLeft($text, 5))
                        GuiCtrlSetState($dmy, 256)
                EndIf
        EndIf
EndFunc        ;==>_wmCommand()
发表于 2009-1-28 21:11:32 | 显示全部楼层
帮助里有例子
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
        Local $hCombo

        ; Create GUI
        GUICreate("ComboBox Limit Text", 400, 296)
        $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
        GUISetState()

        ; Limit text in edit box
        _GUICtrlComboBox_LimitText($hCombo, 10)
        
        ; Add files
        _GUICtrlComboBox_BeginUpdate($hCombo)
        _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
        _GUICtrlComboBox_EndUpdate($hCombo)
        
        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>_Main
发表于 2009-1-28 22:06:29 | 显示全部楼层
因为用了 新版的 帮助.......udf是双语 目录 .......没看到有这udf
只想说那句

大意了 大意了
 楼主| 发表于 2009-1-29 11:29:49 | 显示全部楼层
感谢各位热心的朋友,问题解决了`!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 01:14 , Processed in 0.076643 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表