private void listBox_Scroll(object Sender, BetterListBox.BetterListBoxScrollArgs e) { BetterListBox listBox = (BetterListBox)Sender; if (listBox.SelectedIndex != -1) { listBox.SetSelected(listBox.SelectedIndex, false); } listBox.SetSelected(e.Top, true); }
private void BindStepConditions(int step_id) { var stepConditions = dal.GetStepConditions(step_id); int countDB = stepConditions.Count(); int countGUI = 0; while (groupBoxConditions.Controls.ContainsKey("listBoxConditionType" + (++countGUI).ToString())) { ; } for (int i = 1; i < countGUI; i++) { if (countDB >= i) { BetterListBox lbox = ((BetterListBox)groupBoxConditions.Controls["listBoxConditionType" + i.ToString()]); lbox.SelectedItem = stepConditions.ElementAt(i - 1).Type; int index = lbox.Items.IndexOf(lbox.SelectedItem); lbox.SetSelected(index, true); ((TextBox)groupBoxConditions.Controls["textBoxConditionSource" + i.ToString()]).Text = stepConditions.ElementAt(i - 1).Source; ((TextBox)groupBoxConditions.Controls["textBoxConditionTarget" + i.ToString()]).Text = stepConditions.ElementAt(i - 1).TargetValue; ((TextBox)groupBoxConditions.Controls["textBoxConditionSourceAttribute" + i.ToString()]).Text = stepConditions.ElementAt(i - 1).SourceAttribute; ((TextBox)groupBoxConditions.Controls["textBoxConditionTargetAttribute" + i.ToString()]).Text = stepConditions.ElementAt(i - 1).TargetAttribute; } else { ((BetterListBox)groupBoxConditions.Controls["listBoxConditionType" + i.ToString()]).SelectedItem = 0; ((BetterListBox)groupBoxConditions.Controls["listBoxConditionType" + i.ToString()]).SetSelected(0, true); ((TextBox)groupBoxConditions.Controls["textBoxConditionSource" + i.ToString()]).Text = ""; ((TextBox)groupBoxConditions.Controls["textBoxConditionTarget" + i.ToString()]).Text = ""; ((TextBox)groupBoxConditions.Controls["textBoxConditionSourceAttribute" + i.ToString()]).Text = ""; ((TextBox)groupBoxConditions.Controls["textBoxConditionTargetAttribute" + i.ToString()]).Text = ""; } } }