Based on the fact that you are working with Tutorial 2 I'll assume the following:
When you're talking about
If you have a look at the code of the dgvAttributeTable_SelectionChanged you'll see that it already handles the case of more than one line beeing selected. You have to set your dgvAttributeTables MultiSelect to true, to be able to select more than one row.
Below you can also see how get the name of the clicked state. Have a look at the //<- comments I added in the code
dgvAttributeTable.SelectedRows is the list of all your selected states.
When you're talking about
I click on a state I can trigger the selection changed eventyou mean that you selected a state in the dgvAttributeTable and therefore raised the dgvAttributeTable_SelectionChanged event.
If you have a look at the code of the dgvAttributeTable_SelectionChanged you'll see that it already handles the case of more than one line beeing selected. You have to set your dgvAttributeTables MultiSelect to true, to be able to select more than one row.
Below you can also see how get the name of the clicked state. Have a look at the //<- comments I added in the code
dgvAttributeTable.SelectedRows is the list of all your selected states.
private void dgvAttributeTable_SelectionChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dgvAttributeTable.SelectedRows) //<- this runs through all selected rows
{
MapPolygonLayer stateLayer = default(MapPolygonLayer);
stateLayer = (MapPolygonLayer)map1.Layers[0];
if (stateLayer == null)
{ MessageBox.Show("The layer is not a polygon layer."); }
else
{
stateLayer.SelectByAttribute("[STATE_NAME] =" + "'" + row.Cells["STATE_NAME"].Value + "'"); //<- row.Cells["STATE_NAME"].Value is the name of your state
}
}
If this wasn't what you were talking about explain more clearly what you are doing so that we don't have to guess what the answer could be.