using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;
namespace WinFormsApp1
{
internal class CreateNewCustomerTab
{
internal static void CreateNewCustomer(TabControl tabControl, string tabName)
{
// Create a new TabPage
TabPage newTab = new TabPage(tabName);
// Create controls: Label and TextBox for Account Number
Label acctNumLabel = new Label();
acctNumLabel.Text = "Account Number:";
acctNumLabel.Width = 300;
acctNumLabel.ForeColor = Color.Black;
acctNumLabel.Location = new Point(38, 15);
TextBox acctNumTextBox = new TextBox();
acctNumTextBox.Location = new Point(56, 22);
acctNumTextBox.Name = "acctNumTextBox";
acctNumTextBox.Enabled = false; // Prevent user input
acctNumTextBox.ReadOnly = true; // Read-only
// Generate a random account number and display it in the TextBox
Random random = new Random();
int accountNumber = random.Next(1000, 10000); // Change this range as needed
acctNumTextBox.Text = accountNumber.ToString();
// Add controls to the new tab's Controls collection
newTab.Controls.Add(acctNumLabel);
newTab.Controls.Add(acctNumTextBox);
// Add the new tab to the TabControl
tabControl.TabPages.Add(newTab);
// Show the newly added tab immediately
tabControl.SelectedTab = newTab;
// Refresh the control
tabControl.Refresh();
}
}
}