Example #1
0
        private void GoToLine()
        {
            if (dataGridView1.Rows.Count > 0)
            {
                var startValue = Convert.ToInt32(dataGridView1[0, 0].Value);
                var endValue   = Convert.ToInt32(dataGridView1[0, dataGridView1.RowCount - 1].Value);

                using (var goToLineForm = new GoToLineForm(startValue, endValue))
                {
                    var dialogResult = goToLineForm.ShowDialog();

                    if (dialogResult == DialogResult.OK)
                    {
                        var rowIndex = GetRowIndexByIndexValue(goToLineForm.LineNumber);

                        if (rowIndex != null)
                        {
                            dataGridView1.CurrentCell = dataGridView1.Rows[rowIndex.Value].Cells[0];
                        }
                    }
                }
            }
        }
Example #2
0
        private void GoToLine()
        {
            if (dataGridView1.Rows.Count <= 0)
            {
                return;
            }

            int startValue;
            int endValue;

            if (!int.TryParse(dataGridView1[0, 0].Value as string, out startValue))
            {
                MessageBox.Show(this, "Only table WADLogsTable supports GoToLine.", $"I'm sorry, {Environment.UserName}. I'm afraid I can't do that.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!int.TryParse(dataGridView1[0, dataGridView1.RowCount - 1].Value as string, out endValue))
            {
                MessageBox.Show(this, "Only table WADLogsTable supports GoToLine.", $"I'm sorry, {Environment.UserName}. I'm afraid I can't do that.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            using (var goToLineForm = new GoToLineForm(startValue, endValue))
            {
                var dialogResult = goToLineForm.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    var rowIndex = GetRowIndexByIndexValue(goToLineForm.LineNumber);

                    if (rowIndex != null)
                    {
                        dataGridView1.CurrentCell = dataGridView1.Rows[rowIndex.Value].Cells[0];
                    }
                }
            }
        }