}//DataSourceChanged /// <summary> /// Форматирование вывода в ListBox. /// </summary> /// <param name="autoCompleteListBox">Выпадающий список.</param> /// <param name="e"></param> public static void OutputFormatting(ListBox autoCompleteListBox, ListControlConvertEventArgs e) { //Находим максимальную ширину каждого параметра. Tuple <int, int, int> columnsWidth = autoCompleteListBox.Tag as Tuple <int, int, int>; int articulMaxLenght = columnsWidth.Item1; int titlelMaxLenght = columnsWidth.Item2; int manufMaxLenght = columnsWidth.Item3; //Задаём нужный формат для выводимых строк. string artCol = String.Format("{{0, {0}}}", -articulMaxLenght); string titleCol = String.Format("{{1, {0}}}", -titlelMaxLenght); string manufCol = String.Format("{{2, {0}}}", -manufMaxLenght); Models.SparePart sparePart = e.ListItem as Models.SparePart; e.Value = String.Format(artCol + " " + titleCol + " " + manufCol, sparePart.Articul, sparePart.Title, sparePart.Manufacturer); } //OutputFormatting
public void InsertSparePart(Models.SparePart sparePart) { context.SpareParts.Add(sparePart); }