MultiSelect doesn't work

Jul 24, 2008 at 2:04 PM
Hi,

is it possible, that the property "MultiSelect" has no effect on the control?
I set "MultiSelect=false" at design-time --> No effect
I set "MultiSelect=false" at run-time --> No effect

I looked into the source code and found out, that the property "MultiSelect" just set the property "AllowMultiSelect" in the ListSection class, but this property "AllowMultiSelect" is never used again.

Any ideas?

Regards
Calimero
Jul 29, 2008 at 10:05 AM
Hi at all,

I've found the solution for the problem by myself. There's a small bug in the method "SetFocusWithSelectionCheck" in the ListSection.cs. When you set "MultiSelect=false", the user is still able to select multiple items by holding down the Ctrl-key (just try it). Selecting mutliple items by holding down the Shift-key is properly working when "MultiSelect" is set to false. This is, because the property AllowMultiSelect is not observed in the part of the code, where the Ctrl-key is checked.

Here's the corrected code:
if (ctrlBeingPressed)
{
    if (SelectedItems.IsSelected(si.RowIdentifier))
    {
        SelectedItems.RemoveInternal(si.RowIdentifier);
    }
    else
    {
        if (AllowMultiSelect)
        {
            // if MultiSelect is set to true, add the newly clicked item to the selected items collection
            SelectedItems.AddInternal(si.RowIdentifier);
        }
        else
        {
            // if MutliSelect is set to false, clear the selected items collection and add the newly clicked item.
            SelectedItems.ClearAndAdd(si.RowIdentifier);
        }
    }
}
else
{
    ....
}

Regards
Calimero

Coordinator
Sep 24, 2008 at 8:42 PM
Hey thanks for that, I've updated the source code with your fix!

Sorry for not responding to you, i've been really busy on projects that put clothes on my back :-)

Thanks again

Lee