private void button4_Click(object sender, System.EventArgs e)
{
//create the form with the SymbologyControl
Form2 symbolForm = new Form2();
//Get the IStyleGalleryItem that has been selected in the SymbologyControl
IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLinePatches);
//release the form
symbolForm.Dispose();
if (styleGalleryItem == null)
{
return;
}
//Find the legend
IElement element = axPageLayoutControl1.FindElementByName("Legend", 1);
if (element == null)
{
return;
}
//Get the IMapSurroundFrame
IMapSurroundFrame mapSurroundFrame = (IMapSurroundFrame)element;
if (mapSurroundFrame == null)
{
return;
}
//If a legend exists change the default area patch
ILegend legend = (ILegend)mapSurroundFrame.MapSurround;
legend.Format.DefaultLinePatch = (ILinePatch)styleGalleryItem.Item;
//Update the legend
legend.Refresh();
//Refresh the display
axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}