i need to show/hide a labelLayer in my c# application with a checkbox, but i have an issue that when label shows ( checkbox checked ) it does'nt hide whene the checkbox is unchecked,
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
SharpMap.Layers.LabelLayer labelLayer = new SharpMap.Layers.LabelLayer("nom commune");
PostGIS quart_pos = new PostGIS("Server=localhost;Port=5432;User=postgres;Password=aaaaaa;Database=MiniProjet", "quartierr", "geom", "libelle");
VectorLayer countriesLayer = new VectorLayer("quartier", quart_pos);
labelLayer.DataSource = countriesLayer.DataSource;
labelLayer.LabelColumn = "NAME";
labelLayer.Style.CollisionDetection = true;
labelLayer.Style.CollisionBuffer = new SizeF(10, 10);
labelLayer.MultipartGeometryBehaviour =
SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest;
labelLayer.Style.Font = new Font(FontFamily.GenericSansSerif, 8);
if (checkBox1.Checked == true)
{
labelLayer.Style.ForeColor = Color.Black;
carte.Layers.Add(labelLayer);
Refresh();
}
else if(checkBox1.Checked == false)
{
carte.Layers.Remove(labelLayer);
Refresh();
}
}
Aucun commentaire:
Enregistrer un commentaire