BrightIdeasSoftware.VirtualObjectListView.SelectObject C# (CSharp) Method

SelectObject() public method

Select the row that is displaying the given model object. All other rows are deselected.
public SelectObject ( object modelObject, bool setFocus ) : void
modelObject object Model object to select
setFocus bool Should the object be focused as well?
return void
        public override void SelectObject(object modelObject, bool setFocus)
        {
            // Without a data source, we can't do this.
            if (this.VirtualListDataSource == null)
                return;

            // Check that the object is in the list (plus not all data sources can locate objects)
            int index = this.VirtualListDataSource.GetObjectIndex(modelObject);
            if (index < 0 || index >= this.VirtualListSize)
                return;

            // If the given model is already selected, don't do anything else (prevents an flicker)
            if (this.SelectedIndices.Count == 1 && this.SelectedIndices[0] == index)
                return;

            // Finally, select the row
            this.SelectedIndices.Clear();
            this.SelectedIndices.Add(index);
            if (setFocus)
                this.SelectedItem.Focused = true;
        }