У меня есть следующий код
Это должно добавить вкладки к элементу управления вкладками... проблема в том, что я не могу увидеть изменения, если отредактирую размер шрифта размера панели и т. д.
Есть ли способ просматривать или редактировать с помощью визуального дизайнера динамические элементы? Я знаю, что это сложно, потому что он не статический, но, поскольку объект объявлен, мне было интересно, есть ли способ установить или просмотреть свойства, используя его, вместо того, чтобы просматривать десятки свойств в зависимости от того, сколько объектов вы создаете. Чего мне не хватает?
Заранее спасибо!
private void AddDynamicTabs()
{
List 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;
// 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);
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... ab-control
Добавление динамических вкладок в элемент управления вкладками ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение