PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Ian Bayly on January 11, 2010, 01:11:24 AM

Title: Can someone help with usage of "GetItemData" in combobox 3.05 XP Pro SP3
Post by: Ian Bayly on January 11, 2010, 01:11:24 AM
Hi
Reading from a DB table into a ListView, I can store the key of a record in Col 0 and make this column zero width.  THis makes subsequent record manipulation simple
Reading the functions in FF3 it appears I can do much the same thing with a combobox using set/get ItemData.  I have had no luck and show simple code from a test project below.
Maybe I am misunderstanding the use of GetItemData and also, I'm not fully comfortable with my understanding of "The 32-bit value to be associated the the string"!

Any help much appreciated.

Ian B

~~~~~~~~~~~
'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long
                         
Dim lRow As Long
Dim nValue As Long
lRow = FF_ComboBox_AddString( HWND_FORM1_COMBO1, "Line 1" )
FF_ComboBox_SetItemData( HWND_FORM1_COMBO1, lRow, 0 )
End Function
'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long
Dim sIndex As String
sIndex = FF_ComboBox_GetItemData( HWND_FORM1_COMBO1, 0 )  <<< Compiler errors with message "String operand expected"
MsgBox sIndex
End Function
~~~~~~~~~




Title: Re: Can someone help with usage of "GetItemData" in combobox 3.05 XP Pro SP3
Post by: Rolf Brandt on January 11, 2010, 04:35:10 AM
Hi Ian,

the problem is here:
QuotesIndex = FF_ComboBox_GetItemData( HWND_FORM1_COMBO1, 0 )

You are trying to assign a long value to a string var. You need to convert to a string first:

sIndex = Format$(FF_ComboBox_GetItemData( HWND_FORM1_COMBO1, 0 ))

I attached a litte demo.

Regards
Rolf
Title: Re: Can someone help with usage of "GetItemData" in combobox 3.05 XP Pro SP3
Post by: Ian Bayly on January 11, 2010, 10:47:38 PM
Thanks for your help Rolf.

When I saw your reply the "penny dropped" immediately.
Why didn't I pay attention when the compiler was trying to tell me the solution?

Must be old age catching up!

Again thanks

Ian B