private void populateList(string[] itemarr, int offset, int itemcount)
{
dataGridView1.Rows.Clear();
dataGridView1.Columns.Clear();
DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
{
dgvIndex.HeaderText = "CNT";
dgvIndex.DisplayIndex = 1;
dgvIndex.Width = 45;
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
DataGridViewComboBoxColumn dgvItemVal = new DataGridViewComboBoxColumn
{
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
};
{
foreach (string t in itemarr)
dgvItemVal.Items.Add(t); // add only the Item Names
dgvItemVal.DisplayIndex = 0;
dgvItemVal.Width = 135;
dgvItemVal.FlatStyle = FlatStyle.Flat;
}
dataGridView1.Columns.Add(dgvItemVal);
dataGridView1.Columns.Add(dgvIndex);
dataGridView1.Rows.Add(itemcount);
dataGridView1.CancelEdit();
string itemname = "";
for (int i = 0; i < itemcount; i++)
{
int itemvalue = BitConverter.ToUInt16(sav, offset + i*4);
try { itemname = Form1.itemlist[itemvalue]; }
catch
{
Util.Error("Unknown item detected.", "Item ID: " + itemvalue, "Item is after: " + itemname);
continue;
}
int itemarrayval = Array.IndexOf(itemarr,itemname);
if (itemarrayval == -1)
{
dataGridView1.Rows[i].Cells[0].Value = itemarr[0];
dataGridView1.Rows[i].Cells[1].Value = 0;
Util.Alert(itemname + " removed from item pouch.", "If you exit the Item Editor by saving changes, the item will no longer be in the pouch.");
}
else
{
dataGridView1.Rows[i].Cells[0].Value = itemarr[itemarrayval];
dataGridView1.Rows[i].Cells[1].Value = BitConverter.ToUInt16(sav, offset + i * 4 + 2);
}
}
}
private void dropclick(object sender, DataGridViewCellEventArgs e)