private void btnAddGroup_Click(object sender, EventArgs e) { var map = this.Viewer.GetMap(); if (map != null) { var diag = new Live.NewGroupDialog(map); if (diag.ShowDialog() == DialogResult.OK) { var mapSvc = (IMappingService)map.CurrentConnection.GetService((int)ServiceType.Mapping); var group = mapSvc.CreateMapGroup(map, diag.GroupName); group.LegendLabel = diag.GroupLabel; group.Visible = true; group.ShowInLegend = true; map.Groups.Add(group); legendCtrl.Viewer.RefreshMap(); } } }