hi I have a DataGridview in with 15 items. Starting from the 5th item, I want to get 14 of them to array. I want to go back to the begin after the last element of datagridview
public partial class exmple : Form
{
public exmple()
{
InitializeComponent();
}
private DataGridView MyDw(DataGridView DVG)
{
for (int i = 1; i <= 15; i++)
{
DataGridViewRow CreateRow = new DataGridViewRow();
CreateRow.CreateCells(DVG);
CreateRow.Cells[0].Value = i-1;
CreateRow.Cells[1].Value = "A"+i;
DVG.Rows.Add(CreateRow);
}
DVG.Columns[0].Width = 50;
DVG.Columns[1].Width = 25;
DVG.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DVG.RowHeadersVisible = false;
return DVG;
}
private void exmple_Load(object sender, EventArgs e)
{
MyDw(dataGridView1);
}
private void button1_Click(object sender, EventArgs e)
{
int beginrow = 5;
ArrayList MyArray = new ArrayList { };
for (int i = 0; i < 14; i++)
{
MyArray.Add(dataGridView1.Rows[beginrow + i].Cells[1].Value.ToString().Trim());
}
}
}