void CF(float s, bool wf) { theme.FontSize = s; theme.WindowsFrame = wf; ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = 430; int ctrlleft = 150; Type t = typeof(DataGridViewDialogs); int initialvalue = 200; Form parent = this; f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Jump to:".Tx(t), new Point(10, 40), new Size(140, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("Entry", typeof(ExtendedControls.NumberBoxLong), initialvalue.ToString(), new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter number to jump to or near to".Tx(t, "EN")) { numberboxdoubleminimum = 0, numberboxformat = "0" }); f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".Tx(), new Point(width - 100, 70), new Size(80, 24), "Press to Accept".Tx(t))); f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "Cancel".Tx(), new Point(width - 200, 70), new Size(80, 24), "Press to Cancel".Tx(t))); f.Trigger += (dialogname, controlname, tag) => { if (controlname == "OK" || controlname == "Entry:Return") { long?v3 = f.GetLong("Entry"); if (v3.HasValue) { f.DialogResult = DialogResult.OK; f.Close(); } else { ExtendedControls.MessageBoxTheme.Show(parent, "Value is not valid".Tx(t, "VNV"), "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (controlname == "Cancel") { f.DialogResult = DialogResult.Cancel; f.Close(); } }; DialogResult res = f.ShowDialogCentred(parent, parent.Icon, "Jump to Entry".Tx(t, "Title")); if (res == DialogResult.OK) { int target = (int)f.GetLong("Entry").Value; } }
public static int JumpToDialog(this DataGridView grid, Form parent, int initialvalue, Func <DataGridViewRow, int> getindex) { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = 430; int ctrlleft = 150; Type t = typeof(DataGridViewDialogs); f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Jump to:".TxID(EDTx.DataGridViewDialogs_Jumpto), new Point(10, 40), new Size(140, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("Entry", typeof(ExtendedControls.NumberBoxLong), initialvalue.ToString(), new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter number to jump to or near to".TxID(EDTx.DataGridViewDialogs_EN)) { numberboxdoubleminimum = 0, numberboxformat = "0" }); f.AddOK(new Point(width - 100, 70), "Press to Accept".TxID(EDTx.DataGridViewDialogs_PresstoAccept)); f.AddCancel(new Point(width - 200, 70), "Press to Cancel".TxID(EDTx.DataGridViewDialogs_PresstoCancel)); f.Trigger += (dialogname, controlname, tag) => { if (controlname == "OK" || controlname == "Entry:Return") { long?v3 = f.GetLong("Entry"); if (v3.HasValue) { f.ReturnResult(DialogResult.OK); } else { ExtendedControls.MessageBoxTheme.Show(parent, "Value is not valid".TxID(EDTx.DataGridViewDialogs_VNV), "Warning".TxID(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (controlname == "Cancel" || controlname == "Close") { f.ReturnResult(DialogResult.Cancel); } }; DialogResult res = f.ShowDialogCentred(parent, parent.Icon, "Jump to Entry".TxID(EDTx.DataGridViewDialogs_Jumpto), closeicon: true); if (res == DialogResult.OK) { int target = (int)f.GetLong("Entry").Value; int rowclosest = 0; int rowdist = int.MaxValue; foreach (DataGridViewRow r in grid.Rows) { if (r.Visible) { int index = getindex(r); int delta = Math.Abs(target - index); if (delta < rowdist) { rowdist = delta; rowclosest = r.Index; } } } grid.DisplayRow(rowclosest, true); return(rowclosest); } else { return(-1); } }