How do I find the section of a specified column and row?
I am having a datagridview as a table,as you can see in the picture below.
In the datagridview, the cells are containing rules. (TE',1) means it is the rule TE', and it is the 1st rule.
My task is like I have an expression, such as i+i*i, and using "rules" as showed in the first columns, I find the value of the cell in the datagridview, which's column is the first character of the expression, and which's row is the first character of the second part. I know it sounds nonsense at first, but let me clear this with an example.
The first step is (i+i*i#,E#,empty). I check the first character of the first part, its i, I check the first character of the second part, its E, I look for the section of column i and row E. It is (TE',1), so in the starting step, I replace E for the cell value TE', and add the number 1 for the third part, which was empty at the beginning. Now the actual "formula" is like:
(i+i*i#,TE',1)
I replaced the second part with the "rule" I found at the cell, and added the number of the rule to the third part of the formula.
Next step, I find the section of column i and row T, it is (FT',4), so I replace T with FT', and add the number 4 to the third part.
(i+i*i#, FT'E'#,14)
Now I Look for the section of column i and row F , its (i,8). I do the replace again.
(i+i*i#,iT'E'#,148)
Now for column i and row i its a pop, so i remove both from the formula.
(+i*i#,T'E'#,148)
Now I look for the column + and row T'.......
The whole procedure ends when there are only # and numbers in the formula, like (#,#,1942682).
I filled the datagridview like this (I am also very sorry about this ..):
private void AddRows()
{
string[] header_Row = new string[] { "", "+", "*", "(", ")", "i", "#", };
dataGridView.Rows.Add(header_Row);
string[] E_Row = new string[] { "E", "", "", "(TÉ,1)", "", "(TÉ,1)", "" };
dataGridView.Rows.Add(E_Row);
string[] EComma_Row = new string[] { "É", "(+TÉ,2)", "", "", "(Eps,3)", "", "(Eps,3)" };
dataGridView.Rows.Add(EComma_Row);
string[] T_Row = new string[] { "T", "", "", "(FT',4)", "", "(FT',4)", "" };
dataGridView.Rows.Add(T_Row);
string[] TComma_Row = new string[] { "T'", "(Eps,6)", "(+FT',5)", "", "(Eps,6)", "", "(Eps,6)" };
dataGridView.Rows.Add(TComma_Row);
string[] F_Row = new string[] { "F", "", "", "(E,7)", "", "(i,8)", "" };
dataGridView.Rows.Add(F_Row);
string[] emptyRow = new string[] { };
dataGridView.Rows.Add(emptyRow);
string[] Plus_Row = new string[] { "+", "pop", "", "", "", "", "" };
dataGridView.Rows.Add(Plus_Row);
string[] Star_Row = new string[] { "*", "", "pop", "", "", "", "" };
dataGridView.Rows.Add(Star_Row);
string[] StartingBracket_Row = new string[] { "(", "", "", "pop", "", "", "" };
dataGridView.Rows.Add(StartingBracket_Row);
string[] EndingBracket_Row = new string[] { ")", "", "", "", "pop", "", "" };
dataGridView.Rows.Add(EndingBracket_Row);
string[] i_Row = new string[] { "i", "", "", "", "", "pop", "" };
dataGridView.Rows.Add(i_Row);
string[] Hashmark_Row = new string[] { "#", "", "", "", "", "", "Elfogad" };
dataGridView.Rows.Add(Hashmark_Row);
}
So the problem is that if I have the first formula (i+i*i#,E#,empty), how do I search for the i column's and E row's section in the datagridview, to get the value of that cell?