Jump to content

set text in a combo input


Go to solution Solved by Melba23,

Recommended Posts

Posted

Have you tried:

$Input1 = GuiCtrlCreatecombo("These|Are|different|Drop|downs", 10, 10, 100, 20)

  • Moderators
Posted

Merchants,

You need a "cuebanner": :)

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "These|are|the|selections")
_GUICtrlComboBox_SetCueBanner($cCombo, "Not a selection")

$cButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
GUICtrlSetState($cButton, $GUI_FOCUS)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Note that the text is only visible when the combo does not have focus - which is why I added the button. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

M23 not bad, but it was not what i was looking for

i know one solution but only if there is no other way

can you confirm this M23?

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
$hGUI = GUICreate("Test", 500, 500)
$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "These|are|the|selections")
_GUICtrlComboBox_SetCueBanner($cCombo, "Not a selection")
$cButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
$testButton = GUICtrlCreateButton("Test2", 10, 100, 80, 30)
GUICtrlSetState($cButton, $GUI_FOCUS)
GUISetState()
While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    Case $testButton
        ControlSetText("[CLASS:AutoIt v3 GUI]", "", "[CLASS:Edit; INSTANCE:1]", "New Text Here" )
    EndSwitch
WEnd
  • Moderators
Posted

Merchants,

 

M23 not bad, but it was not what i was looking for

But it is exactly what you asked for - you need to explain your requirements more carefully in future. ;)

If you want to rest the cuebanner within the script then you just need to redefine it: :)

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "These|are|the|selections")
_GUICtrlComboBox_SetCueBanner($cCombo, "Not a selection")

$cButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
$testButton = GUICtrlCreateButton("Test2", 10, 100, 80, 30)
GUICtrlSetState($cButton, $GUI_FOCUS)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $testButton
            _GUICtrlComboBox_SetCueBanner($cCombo, "New text here")
    EndSwitch
WEnd
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

you need to explain your requirements more carefully in future. ;)

 

i am sorry but i have done that

i want to set text in a combo input without make a item of it

 

i want to use/edit the new text in the combo input not when i click it and it disappears..

if i use GUICtrlSetData then it wil make a item of it and that is not what i want

that was my requirements

Edited by Merchants
  • Moderators
  • Solution
Posted

Merchants,

I understand now - and the only way I can imagine it is possible is the method you have shown above, although you can streamline the syntax a bit: :)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "|These|are|the|selections")
ControlSetText($hGUI, "", $cCombo, "Not a selection")

$cButton = GUICtrlCreateButton("Change Text", 10, 50, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            ControlSetText($hGUI, "", $cCombo, "Nor is this a selection either")
    EndSwitch
WEnd
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

here (_GUICtrlComboBox_GetEditText):

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "These|are|the|selections")
_GUICtrlComboBox_SetCueBanner($cCombo, "Not a selection")

$cButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
$testButton = GUICtrlCreateButton("Test2", 10, 100, 80, 30)
$test2Button = GUICtrlCreateButton("Test3", 10, 150, 80, 30)
GUICtrlSetState($cButton, $GUI_FOCUS)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $testButton
            _GUICtrlComboBox_SetCueBanner($cCombo, "New text here")
        Case $test2Button
            ConsoleWrite(_GUICtrlComboBox_GetEditText($cCombo) & @CRLF)
    EndSwitch
WEnd

edit: oops, I got the requirement backwards...I think.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

I understand now - and the only way I can imagine it is possible is the method you have shown above, although you can streamline the syntax a bit: :)

ok then i wil use that

quick question: the combo box can show 30 items when clicked down by default is there a way to increased that?

i wana see 50 items without scrolling down for it

Edited by Merchants
Posted

check out the function lists in the helpfile...they are named exactly like what they do:

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "These|are|the|selections|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|1|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!!|!")
_GUICtrlComboBox_SetMinVisible($cCombo,_GUICtrlComboBox_GetCount($cCombo))

_GUICtrlComboBox_SetCueBanner($cCombo, "Not a selection")

$cButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
$testButton = GUICtrlCreateButton("Test2", 10, 100, 80, 30)
$test2Button = GUICtrlCreateButton("Test3", 10, 150, 80, 30)
GUICtrlSetState($cButton, $GUI_FOCUS)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $testButton
            _GUICtrlComboBox_SetCueBanner($cCombo, "New text here")
        Case $test2Button
            ConsoleWrite(_GUICtrlComboBox_GetEditText($cCombo) & @CRLF)
    EndSwitch
WEnd
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

 

check out the function lists in the helpfile...they are named exactly like what they do:

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 300, 20)
GUICtrlSetData($cCombo, "These|are|the|selections|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|1|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!|!!|!")
_GUICtrlComboBox_SetMinVisible($cCombo,_GUICtrlComboBox_GetCount($cCombo))

_GUICtrlComboBox_SetCueBanner($cCombo, "Not a selection")

$cButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
$testButton = GUICtrlCreateButton("Test2", 10, 100, 80, 30)
$test2Button = GUICtrlCreateButton("Test3", 10, 150, 80, 30)
GUICtrlSetState($cButton, $GUI_FOCUS)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $testButton
            _GUICtrlComboBox_SetCueBanner($cCombo, "New text here")
        Case $test2Button
            ConsoleWrite(_GUICtrlComboBox_GetEditText($cCombo) & @CRLF)
    EndSwitch
WEnd
SetMinVisible oké thank you
for you a thumb up 

:thumbsup:

Edited by Merchants

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...