0
I have a following error when passing information of the selected line from a Form1 grid to the form2 grid
Follow the code of the Form1 grid
private void button1_Click(object sender, EventArgs e)
{
for (Int32 index = 0; index < dgw_separacaopic.Rows.Count; index++)
{
if (bool.Parse(dgw_separacaopic.Rows[index].Cells[0].FormattedValue.ToString()) == true)
{
frmSepfatpic sep = new frmSepfatpic();
sep.Pedido = dgw_separacaopic.CurrentRow.Cells[4].Value.ToString();
sep.Show();
}
}
Follow the form2 grid code that is receiving the value
public partial class frmSepfatpic : Form
{
public string Pedido { get; set; }
//public string Item { get; set; }
//public string Cliente { get; set; }
//public string QTDA { get; set; }
public frmSepfatpic()
{
InitializeComponent();
}
private void frmSepfatpic_Load(object sender, EventArgs e)
{
dgw_sepfatpic.CurrentRow.Cells[0].Value = Pedido;
}
}
Lodi thanks for the help, but now this presenting an error that the column index can not be negative..
– Junior Guerreiro
Additional information: The index was out of range. It should be non-negative and smaller than the collection size.In this line dgw_sepfatpic.Columns[1]. Name = "REQUEST";
– Junior Guerreiro
"The index was out of range. It must be non-negative and smaller than the collection size. r nName of parameter: index"}
– Junior Guerreiro
I modified the answer, you must add the column before adding the new row. make a test, if it works do not forget to mark as reply and give an upvote...
– Lodi
Perfect Lodi thank you.
– Junior Guerreiro