/// <summary> /// Selects the item. /// </summary> /// <param name="item">The item.</param> private void SelectItem(UCHorizontalListItem item) { if (SelectedItem != null && !SelectedItem.IsDisposed) { SelectedItem.SetSelect(false); } SelectedItem = item; SelectedItem.SetSelect(true); if (SelectedItemEvent != null) { SelectedItemEvent(item, null); } }
/// <summary> /// Reloads the source. /// </summary> public void ReloadSource() { try { ControlHelper.FreezeControl(this, true); this.panList.SuspendLayout(); this.panList.Controls.Clear(); this.panList.Width = this.panMain.Width; if (DataSource != null) { foreach (var item in DataSource) { UCHorizontalListItem uc = new UCHorizontalListItem(); uc.SelectedColor = selectedColor; uc.DataSource = item; uc.SelectedItem += uc_SelectItem; this.panList.Controls.Add(uc); } } this.panList.ResumeLayout(true); if (this.panList.Controls.Count > 0) { this.panList.Width = panMain.Width + this.panList.Controls[0].Location.X * -1; } this.panList.Location = new Point(0, 0); m_startItemIndex = 0; if (this.panList.Width > panMain.Width) { panRight.Visible = true; } else { panRight.Visible = false; } panLeft.Visible = false; panList.SendToBack(); panRight.SendToBack(); if (isAutoSelectFirst && DataSource != null && DataSource.Count > 0) { SelectItem((UCHorizontalListItem)this.panList.Controls[0]); } } finally { ControlHelper.FreezeControl(this, false); } }