I have the following code
This should add tabs to a tab control… the problem is that Im unable to see the changes if I edit the font size of the panel size, etc.
Also is there a way to see or edit using the visual designer things that are dynamic? I know its hard because its not static, but since the object is declared I was wondering if there is a way to set or see properties using it instead of going through tens of properties depending on how many objects you are creating. What am I missing?
Thanks in advance !
private void AddDynamicTabs()
{
List<Zonas> ZonasList = Database.GetZonasFromDatabase();
Console.WriteLine("CANTIDAD DE ZONAS " + ZonasList.Count);
TAB_ZONAS.TabPages.Clear();
// Calculate tab width based on the width of Panel_mesas and number of zones
int tabWidth = Panel_mesas.Width / ZonasList.Count;
for (int i = 0; i < ZonasList.Count; i++)
{
Zonas zonas = ZonasList[i];
// Create a new tab page
TabPage tabPage = new TabPage(zonas.NOMBRE);
tabPage.Name = $"tabPage_{zonas.NOMBRE}";
tabPage1.Text = $"tabPage_{ zonas.NOMBRE}";
// Set properties for the tab page
tabPage.BackColor = Color.LightGray;
tabPage.ForeColor = Color.Black;
tabPage.Font = new Font("Arial", 25, FontStyle.Bold);
tabPage.Padding = new Padding(10); // Padding around the content of the tab page
tabPage.Margin = new Padding(5); // Margin around the entire tab page
tabPage.Enabled = true; // Enable or disable the tab page
tabPage.UseVisualStyleBackColor = true; // Use the default visual style for the tab page
tabPage.AutoScroll = false; // Enable auto-scrolling for the tab page content
tabPage.RightToLeft = RightToLeft.No; // Set the text direction for right-to-left languages
tabPage.Tag = null; // Set an object that contains data about the tab page
tabPage.ToolTipText = "Tooltip for the tab page"; // Set a tooltip for the tab page
tabPage.Width = 1000;
tabPage.Height = 4100;
// Optionally, set other properties
// Example:
// tabPage.BackgroundImage = yourImage;
// tabPage.BackgroundImageLayout = ImageLayout.Stretch;
// Add the tab page to the TAB_ZONAS TabControl
TAB_ZONAS.TabPages.Add(tabPage);
}
}
Juan Manuel Sanchez Cuellar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.