public void AddItem(string Items) { LogInListBoxItem Item = new LogInListBoxItem(); Item.Text = Items; _Items.Add(Item); Invalidate(); InvalidateScroll(); }
public void AddItems(string[] Items) { foreach (String I_loopVariable in Items) { string I = I_loopVariable; LogInListBoxItem Item = new LogInListBoxItem(); Item.Text = I; _Items.Add(Item); } Invalidate(); InvalidateScroll(); }
protected override void OnPaint(PaintEventArgs e) { Graphics G = e.Graphics; var _with30 = G; _with30.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; _with30.SmoothingMode = SmoothingMode.HighQuality; _with30.PixelOffsetMode = PixelOffsetMode.HighQuality; _with30.Clear(_BaseColour); LogInListBoxItem AllItems = null; int Offset = Convert.ToInt32(VerticalScrollbar.Value * (VerticalScrollbar.Maximum + (Height - (ItemHeight)))); int StartIndex = 0; if (Offset == 0) { StartIndex = 0; } else { StartIndex = Convert.ToInt32(Offset / ItemHeight / VerticalScrollbar.Maximum); } int EndIndex = Math.Min(StartIndex + (Height / ItemHeight), _Items.Count - 1); for (int I = StartIndex; I <= _Items.Count - 1; I++) { AllItems = Items[I]; int Y = (ItemHeight + (I * ItemHeight) + 1 - Offset) + Convert.ToInt32((ItemHeight / 2) - 8); if (_SelectedItems.Contains(AllItems)) { _with30.FillRectangle(new SolidBrush(_SelectedItemColour), new Rectangle(0, ItemHeight + (I * ItemHeight) + 1 - Offset, Width - 19, ItemHeight - 1)); } else { _with30.FillRectangle(new SolidBrush(_NonSelectedItemColour), new Rectangle(0, ItemHeight + (I * ItemHeight) + 1 - Offset, Width - 19, ItemHeight - 1)); } _with30.DrawLine(new Pen(_BorderColour), 0, (ItemHeight + (I * ItemHeight) + 1 - Offset) + ItemHeight - 1, Width - 18, (ItemHeight + (I * ItemHeight) + 1 - Offset) + ItemHeight - 1); _with30.DrawString(AllItems.Text, new Font("Segoe UI", 8), new SolidBrush(_TextColour), 9, Y); _with30.ResetClip(); } _with30.FillRectangle(new SolidBrush(_TitleAreaColour), new Rectangle(0, 0, Width, ItemHeight)); _with30.DrawRectangle(new Pen(Color.FromArgb(35, 35, 35)), 1, 1, Width - 3, ItemHeight - 2); _with30.DrawString(Text, new Font("Segoe UI", 10, FontStyle.Bold), new SolidBrush(_TextColour), new Rectangle(0, 0, Width, ItemHeight + 2), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); _with30.DrawRectangle(new Pen(Color.FromArgb(35, 35, 35), 2), 1, 0, Width - 2, Height - 1); _with30.DrawLine(new Pen(_BorderColour), 0, ItemHeight, Width, ItemHeight); _with30.DrawLine(new Pen(_BorderColour, 2), VerticalScrollbar.Location.X - 1, 0, VerticalScrollbar.Location.X - 1, Height); _with30.InterpolationMode = (InterpolationMode)7; }
public void RemoveItem(LogInListBoxItem item) { _Items.Remove(item); Invalidate(); InvalidateScroll(); }