private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; if (node.Tag is MapZone) { MapZone zone = node.Tag as MapZone; propertyGrid.SelectedObject = zone.Properties; imageGrid.ClearSelection(); foreach (CoordXZ tileCoord in zone.Tiles) { imageGrid.AddSelectedCell(tileCoord.x + gridOffset.x, tileCoord.z + gridOffset.z); } } else if (node.Tag is MapLayer) { MapLayer layer = node.Tag as MapLayer; propertyGrid.SelectedObject = layer.Properties; imageGrid.ClearSelection(); } else { propertyGrid.SelectedObject = null; imageGrid.ClearSelection(); } }