0% found this document useful (0 votes)
8 views3 pages

Create Controls User Defined CSharp

The document contains code for creating a dynamic seating arrangement form with user controls for rows and seats. It includes classes for the form, row, and seat controls and code to select/deselect seats and add them to a list on the main form.

Uploaded by

Razvan Trufin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Create Controls User Defined CSharp

The document contains code for creating a dynamic seating arrangement form with user controls for rows and seats. It includes classes for the form, row, and seat controls and code to select/deselect seats and add them to a list on the main form.

Uploaded by

Razvan Trufin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace randomdinamic
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public List<string> slist = new List<string>();
public bool addNewString(string g)
{
slist.Add(g);
this.textBox1.Text += g + "\r\n";
return true;
}
private void Form1_Load(object sender, EventArgs e)
{

}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace randomdinamic
{
public partial class rowseats : UserControl
{
public rowseats()
{
InitializeComponent();
}
public void setLabelText(string x)
{
this.label1.Text = x;
}
private void rowseats_Load(object sender, EventArgs e)
{
label1.Text = "Row No:" + this.Name;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace randomdinamic
{
public partial class seat : UserControl
{
public seat()
{
InitializeComponent();
}
public Form1 f;
public rowseats r;
public bool isSelected = false;
public void setAsNotOccupied()
{
if (isSelected == false)
{
BackColor = Color.Red;
}
}
public void setAsOccupied()
{
if (isSelected == true)
{
BackColor = Color.Green;
}
}
public void setLabelText(string x)
{
this.label1.Text = x;
}
public bool switchSelectedCase()
{
if (isSelected == true) { isSelected = false;
setAsNotOccupied(); return false; }
else { isSelected = true; setAsOccupied(); return true; }
}
private void seat_DoubleClick(object sender, EventArgs e)
{
switchSelectedCase();
try { f.addNewString(this.r.Name + " : " + this.label1.Text); }
catch { }

private void seat_Load(object sender, EventArgs e)


{
try
{
this.r = (rowseats)this.Parent;
}
catch { }

try {
this.f = (Form1)this.r.ParentForm;
}
catch { }

label1.Text = "Seat No:" + "\r\n" + this.Name;


}
}
}

You might also like