Jump to content

GuiCtrlSetData for a Combo Box


Eru
 Share

Recommended Posts

I have a code that lets me save alternate configuration settings to a .ini file. It writes to the ini like so:

[settings]

Options=Option1|Option2|

Option1= zzz

Option2= xxx

When I save a new setting, it appends the name of it to the Options key, and adds the value to the end. I use a combo box ($Settings) to pick between the options. When It's saved, i use the GUICtrlSetData command to reset the combo box with the options.

Problem is, when I use GuiCtrlSetData on it, it keeps all the old options, then adds the new ones. For instance, if I added Option3=yyy my combo box would look like this:

Option1

Option2

Option1

Option2

Option3

If i close the program and restart it, the combo displays correctly. Is there a way to clear the data that's in the combo box, and then reassign the data to it like i've been doing? Or am I going to have to make a wierd workaround for it? :/

Thanks everyone :whistle:

Link to comment
Share on other sites

Nevermind, I've found a workaround. I just GUICtrlDelete the control, the remake it and reassign it. :whistle:

Use A pipe character ("|") at the begining of the GUICtrlSetData string'

GUICtrlSetData($MyCombo, "|" & $MyList)

OR

GUICtrlSetData($MyCombo,'')

GUICtrlSetData($MyCombo,$MyList)

The method you used is not good. It may work this time but if you used something like

Assume your combo is $Ctrl4

For $I = $Ctrl1 To $Ctrl7

GUICtrlSetState($I,144)

Next

Then when you delete and recreate $Ctrl4 it will be created at the bottom of your GUICtrls and will no longer be in the For/Next loop so it would not get disabled with the rest

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 2 months later...

Use A pipe character ("|") at the begining of the GUICtrlSetData string'

GUICtrlSetData($MyCombo, "|" & $MyList)

OR

GUICtrlSetData($MyCombo,'')

GUICtrlSetData($MyCombo,$MyList)

The method you used is not good. It may work this time but if you used something like

Assume your combo is $Ctrl4

For $I = $Ctrl1 To $Ctrl7

GUICtrlSetState($I,144)

Next

Then when you delete and recreate $Ctrl4 it will be created at the bottom of your GUICtrls and will no longer be in the For/Next loop so it would not get disabled with the rest

I was facing a similar problem with a combo and that pipe trick did the job!

Thanks GeoSoft!

Why crabs don't give money to charity..... because they are shell-fish!! PS: Don't be a crab and share your scripts with the community! ;-)
Link to comment
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
 Share

  • Recently Browsing   0 members

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