private void FormWaggonsList_Load(object sender, EventArgs e) { var count = WaggonDataKeeper.Count(); vScrollBar1.Maximum = count > 0 ? count - 1 : 0; vScrollBar1.LargeChange = _recordCount; UpdateWaggonsList(); }
private void ShowWaggonInsertDialog() { using (var frm = new FormWaggonDataEditor(false, "", "", 0)) { if (frm.ShowDialog() != DialogResult.OK) { return; } var resultwag = frm.GetValue; if (resultwag == null) { return; } var index = WaggonDataKeeper.Find(resultwag.Number); if (index >= 0) { MessageBox.Show(this, @"Вагон с номером " + resultwag.Number + @" уже существует!", @"Новый вагон", MessageBoxButtons.OK, MessageBoxIcon.Error); vScrollBar1.Value = index; UpdateWaggonsList(0); return; } if (!WaggonDataKeeper.Add(resultwag.Number, resultwag.Ntype, resultwag.FactHeight)) { return; } var count = WaggonDataKeeper.Count(); vScrollBar1.Maximum = count > 0 ? count - 1 : 0; index = WaggonDataKeeper.Find(resultwag.Number); if (index < 0) { return; } vScrollBar1.Value = index; UpdateWaggonsList(0); } }