I want to display a grid of lines on a panel with inputs from a datagridview control. With the number of grids, thus number of datagridview rows known, How can I populate a column in datagridview to hold labels for grids in such a way that the user names the starting grid's name(Say A or 1 or B1) and the remaining grids get named in ascending order to the starting grid name(Say B C D ... OR 2 3 4....or B2 B3 B4.....). I tried with a character array holding the 26 letters, like the following.
public char[] letters = new Char[26] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
public double grid_no_y;
public double grid_no_x;
public double grid_step_y;
public double grid_step_x;
public char xb;
public char yb;
GridSystem gs = new GridSystem();
for (int i = 0; i < gs.dataGridView1.ColumnCount; i++)
{
if (CB_X.Text=="A")
{
for (int j = 0; j < grid_no_x; j++)
{
if (i == 0)
{
gs.dataGridView1.Rows.Add();
}
string x = letters[j].ToString();
double y1 = j * grid_step_x;
string value = "0";
if (i == 0)
value = x;
else if (i == 1)
value = y1.ToString();
gs.dataGridView1[i, j].Value = value.ToString();
}
}
But if the user wants more than 26 elements I get an error. Besides that It does not allow for flexibility of the user(i.e. the user is forced to name the first grid either A or 1) and I want the user to be able to start with any alphanumeric he desires.
I meant the datagridview entries themselves and not the naming of the column/row headers. Some thing of this type:
Column 1 Column2
Grid Name X-Coordinate
F 5
G 10
H 15
I 20
J 30
My concern is column 1 of the datagridview. How can I populate beginning from the user specified starting Index( in the above case for example: F) up.