Jump to content
Sign in to follow this  
iahngy

Add a new item to a listbox from user?

Recommended Posts

iahngy

I am going to create a list with certain items(_GUICtrlListBox_Create) ..but to get new items from user ...I create a single input box then get the data from input box (GUICtrlCreateInput) and display in the list?

what is the best way to display a list and can be added multiple items in by user?

Edited by iahngy

Share this post


Link to post
Share on other sites
PhoenixXL

Example

#include <GUIConstants.au3>

GUICreate(@ScriptName, 300, 350)
$iList = GUICtrlCreateList("", 10, 10, 280, 180)
$btnAdd = GUICtrlCreateButton("Add To List:", 10, 220, 100)
$iInput = GUICtrlCreateInput("", 130, 220, 160)
GUISetState()

Local $sRead
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete()
Exit
Case $btnAdd
$sRead = GUICtrlRead($iInput)
If $sRead <> '' Then GUICtrlSetData($iList, $sRead)
EndSwitch
WEnd

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
PhoenixXL

Another example using the API

#include <GuiListBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main()
Local $hListBox

; Create GUI

GUICreate(@ScriptName, 300, 300)
$hListBox = GUICtrlCreateList("First Line", 10, 10, 280, 180)
$btnAdd = GUICtrlCreateButton("Add To List:", 10, 220, 100)
$iInput = GUICtrlCreateInput("", 130, 220, 160)
GUISetState()


; Loop until user exits
Do
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btnAdd
AddString($hListBox, GUICtrlRead($iInput))
EndSwitch
Until 0
GUIDelete()
EndFunc   ;==>_Main

Func AddString($hListBox, $String)

; Add strings
_GUICtrlListBox_BeginUpdate($hListBox)
_GUICtrlListBox_AddString($hListBox, $String)
_GUICtrlListBox_UpdateHScroll($hListBox)
_GUICtrlListBox_EndUpdate($hListBox)

EndFunc   ;==>AddString


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
iahngy

Thanks PhoenixXL. The 2nd one is cool..is there a list box where i just double click on the item then it is transfered to the another list box ?

Share this post


Link to post
Share on other sites
PhoenixXL

That you have to do !!

check LBN_DBLCLK,

with WM_COMMAND

Search the Forum for some examples

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×