Tell me, please, why can not go into the cycle - the result is empty. In the columns of the letter, in the row of the number, encryption must be performed on the word entered in the textbox ... does not show any errors.
private void button1_Click(object sender, EventArgs e) { string sl = ""; for (int i = 0; i < textBox1.Text.Length; i++) { foreach (DataGridViewColumn col in dataGridView1.Columns) if (col.Name == textBox1.Text[i].ToString()) sl += dataGridView1.CurrentRow.Cells[col.Index].Value; } label1.Text = "Результат: " + sl; } private void Form1_Load(object sender, EventArgs e) { dataGridView1.Rows.Add(2); dataGridView1.Rows[0].Cells[0].Value = 1; dataGridView1.Rows[0].Cells[1].Value = 2; // и т.д. }