The proper way to do this would be using arrays.
As the solution is urgent, you may use the following quick hack to do this.
The following assumes the value gets saved when the button is clicked.
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
txtbox1.Text = "";
if (listView1.SelectedItems.Count > 0)
{
if (listView1.SelectedItems[0].Tag != null)
{
txtbox2.Text = listView1.SelectedItems[0].Tag.ToString();
}
else
{
txtbox2.Text = "";
}
}
}
private void button1_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
listView1.SelectedItems[0].Tag = txtbox1.Text;
txtbox1.Text = "";
MessageBox.Show("Value for " + listView1.SelectedItems[0].Text + " set.");
}
else
{
MessageBox.Show("Please select an item before assigning a value.");
}
}