How do I access the Palettes that are loaded Programmatically using the PaletteGroupBar.LoadPalette()?
Load palettes programmatically
Palettes can be loaded programmatically through the PaletteGroupBar.LoadPalette(). This method returns the instance of the PaletteGroupView control that holds the palette. Once we have the instance of the PaletteGroupView control, it can be accessed easily.
This following code snippet shows the above mentioned informations.
C#
////////////////////////////////////////////////////////////////////////////////////////////////////
/* Add the following code snippet to the DiagramBuilder Sample's MainForm_Load() event method */
////////////////////////////////////////////////////////////////////////////////////////////////////
// Create an instance for the PaletteGroupView class and let the instance hold the reference for the palette files.
PaletteGroupView paletteGroupView = this.symbolPaletteGroupBar.LoadPalette(symbolpalettepath + "\Basic Shapes.edp");
// Set the Back/Fore color for the palette files of your interest by making use of this PaletteGroupView object.
paletteGroupView.BackColor = Color.Red;
paletteGroupView.ForeColor = Color.White;
// Set the BorderStyle and Font property of the palette files.
paletteGroupView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
paletteGroupView.Font = new Font("Arial", 12f, System.Drawing.FontStyle.Bold);
// Set the HighlightItemColor property of the palette files.
paletteGroupView.HighlightItemColor = Color.YellowGreen;
VB
////////////////////////////////////////////////////////////////////////////////////////////////////
/* Add the following code snippet to the DiagramBuilder Sample's MainForm_Load() event method */
////////////////////////////////////////////////////////////////////////////////////////////////////
' Create an instance for the PaletteGroupView class and let the instance hold the reference for the palette files.
Private paletteGroupView As Syncfusion.Windows.Forms.Diagram.Controls.PaletteGroupView
paletteGroupView = Me.symbolPaletteGroupBar.LoadPalette(symbolpalettepath & "\Basic Shapes.edp")
' Set the background color of the palette files of your interest by making use of this PaletteGroupView object.
paletteGroupView.BackColor = System.Drawing.Color.Red
paletteGroupView.ForeColor = System.Drawing.Color.White
' Set the BorderStyle and Font property of the palette files.
paletteGroupView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
paletteGroupView.Font = New Font("Arial", 12f, System.Drawing.FontStyle.Bold)
' Set the HighlightItemColor property of the palette files.
paletteGroupView.HighlightItemColor = Color.YellowGreen
Conclusion
I hope you enjoyed learning about how to access the palettes that are loaded programmatically using the PaletteGroupBar.LoadPalette().
You can refer to WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!