private void LB_DragDrop(object sender, DragEventArgs e) { pr("LB_DragDrop " + L.GetItem(LB.SelectedIndex).ToString() + " " + lbLine.IP.ToString() + " " + L.GetItem(lbLine.CurrentIndex).ToString()); int src = LB.SelectedIndex; pr("scr=" + src); int trg = lbLine.CurrentIndex; if (lbLine.IP == LBLine.InsertPosition.After) { trg++; } if (trg > src) { trg--; } pr(string.Format("{0}: {1} -> {2}", L.ListCount().ToString(), src.ToString(), trg.ToString())); if (L.Move(src, trg)) { LB.Items.Clear(); foreach (object p in L) { LB.Items.Add(p); } LB.SelectedIndex = trg; } }
void ListValue(object sender, EventArgs e) { GridItem g = propertyGrid2.SelectedGridItem; object val = g.Value; GridItem parent = g.Parent; PropertyInfo pi = parent.Value.GetType().GetProperty(g.PropertyDescriptor.Name); if (parent == null) { return; } IParentBase pval = parent.Value as IParentBase; if (pval == null) { return; } IParentList plist = pval.Parent as IParentList; if (plist == null) { return; } ConfirmAttribute cf = Attribute.GetCustomAttribute(pi, typeof(ConfirmAttribute)) as ConfirmAttribute; //if (cf != null) //{ // if (MessageBox.Show("Подтвердите изменения", "Внимание", MessageBoxButtons.OKCancel) == DialogResult.Cancel) // return; //} int count = plist.ListCount(); for (int i = 0; i < count; i++) { object lval = plist.GetItem(i); pi.SetValue(lval, val, null); } propertyGrid2.Refresh(); if (OnRefresh != null) { OnRefresh(); } }