或者如何实现itemdata属性值可以是字符的功能?

解决方案 »

  1.   

    用数组对应listindex想存什么就存什么
      

  2.   

    是从数据表中select出来的会变的,难道每次要该数组?太麻烦了,
    有没有更好的?
      

  3.   

    那就作个自定义控件,实现可以存任何数据类型的itemdata
      

  4.   

    昏倒……要注意对应关系!
    系统的Combo控件的那个属性本来就是DWORD,VB只不过把它映射成了属性
    CB_SETITEMDATA
    An application sends a CB_SETITEMDATA message to set the 32-bit value associated with the specified item in a combo box. CB_SETITEMDATA 
    wParam = (WPARAM) index;            // item index 
    lParam = (LPARAM) (DWORD) dwData;   // item data 
     
    Parameters
    index 
    Value of wParam. Specifies the item's zero-based index. 
    dwData 
    Value of lParam. Specifies the new value to be associated with the item. 
    Return Values
    If an error occurs, the return value is CB_ERR. Res
    If the specified item is in an owner-drawn combo box created without the CBS_HASSTRINGS style, this message replaces the 32-bit value in the lParam parameter of the CB_ADDSTRING or CB_INSERTSTRING message that added the item to the combo box. QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winuser.h.
    CB_GETITEMDATA
    An application sends a CB_GETITEMDATA message to a combo box to retrieve the application-supplied 32-bit value associated with the specified item in the combo box. CB_GETITEMDATA 
    wParam = (WPARAM) index;  // item index 
    lParam = 0;               // not used; must be zero 
     
    Parameters
    index 
    Value of wParam. Specifies the zero-based index of the item. 
    Return Values
    The return value is the 32-bit value associated with the item. If an error occurs, it is CB_ERR. If the item is in an owner-drawn combo box created without the CBS_HASSTRINGS style, the return value is the 32-bit value contained in the lParam parameter of the CB_ADDSTRING or CB_INSERTSTRING message that added the item to the combo box. If the CBS_HASSTRINGS style was not used, the return value is the lParam parameter contained in a CB_SETITEMDATA message.