simple question ..... ppc wm 5.0 device (Axim x51)
Visual Studio 2005 .NET Pro

I created a form, added a listbox and combobox onto this windows mobile form
... can I select multiple items? Can I set the multi-select to true.
I can't even find this property .... what am I missing.

RE: Multi-Select Listbox by dbgrick

dbgrick
Thu Dec 06 09:28:05 PST 2007

Allows check boxes in your list box, then you use the ListView_SetCheckState
and ListView_GetCheckState methods. Check out this MSDN article:

http://msdn2.microsoft.com/en-us/library/ms838348.aspx

Regards,
Rick D.
Contractor

"Tom Holmes Jr." wrote:

> simple question ..... ppc wm 5.0 device (Axim x51)
> Visual Studio 2005 .NET Pro
>
> I created a form, added a listbox and combobox onto this windows mobile form
> .... can I select multiple items? Can I set the multi-select to true.
> I can't even find this property .... what am I missing.
>
>

Re: Multi-Select Listbox by Arun

Arun
Thu Dec 06 16:27:23 PST 2007

You have to probably try using ListView instead of ListBox.
Either you can PInvoke to change the control underlying behaviour to
support multi select or chose Rick's suggestion by adding a check box
column.

using System.Runtime.InteropServices;

private const int GWL_STYLE = -16;
private const int LVS_SINGLESEL = 0x0004;

[DllImport("coredll")]
private static extern IntPtr GetCapture();
[DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("coredll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);

//To multiselect
this.listView1.Capture = true;
IntPtr hWnd = GetCapture();
this.listView1.Capture = false;
int style = GetWindowLong(hWnd, GWL_STYLE);
SetWindowLong(hWnd, GWL_STYLE, (style & ~LVS_SINGLESEL));

if you are using CF2.0, you don't need to use GetCapture and set the
Capture to True/False either, instead control exposes Handle property.
IntPtr hWnd = listview1.Handle;

Loop through the selected indices on the listview to get the items.
ListView.SelectedIndexCollection col =
this.ListView1.SelectedIndices()

Hope this helps,

Cheers,
Arun


On Dec 6, 9:28 am, dbgrick <dbgr...@discussions.microsoft.com> wrote:
> Allows check boxes in your list box, then you use the ListView_SetCheckState
> and ListView_GetCheckState methods. Check out this MSDN article:
>
> http://msdn2.microsoft.com/en-us/library/ms838348.aspx
>
> Regards,
> Rick D.
> Contractor
>
>
>
> "Tom Holmes Jr." wrote:
> > simple question ..... ppc wm 5.0 device (Axim x51)
> > Visual Studio 2005 .NET Pro
>
> > I created a form, added a listbox and combobox onto this windows mobile form
> > .... can I select multiple items? Can I set the multi-select to true.
> > I can't even find this property .... what am I missing.- Hide quoted text -
>
> - Show quoted text -