
6. Work With Forms
Working with Forms in Web Windows Forms
User Interface (UI) Principles
The User Interface (UI) in web development refers to the graphical layout of an application. It includes everything that a user interacts with, such as buttons, text entries, sliders, and more.
Key Points:
- The UI should be visually appealing and color coordinated. It's recommended that you stick to a color scheme of 3 colors, distributed as 60%, 30%, and 10% respectively.
- The text within the UI should be readable.
- Important elements should be more prominent and easily visible.
User Experience (UX) Principles
User Experience (UX), on the other hand, is focused on the overall feel of the experience and the perception of the user as they use the application.
Key Points:
- Elements should be placed intuitively, making it easy for the user to find what they're looking for.
- The application should be easy for the user to operate.
Parent Child Forms
One of the core components of web windows forms is the concept of Parent Child forms. This is a way of organizing and passing information between two forms.
There are 3 main ways to pass information between parent and child forms:
- By Constructor: This is where the child form takes in data through a parameterized constructor provided by the parent form.
- By Property: This involves changing the full property set to pass information.
- By ShowDialog Overloading: This method involves overloading the ShowDialog method to include additional parameters.
To communicate from one form to another (for instance, when an event occurs in one form and another form needs to be notified), we use an EventHandler.
Let's look at an example in C#:
public partial class ParentForm : Form
{
public ParentForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ChildForm childForm = new ChildForm("Hello, Child!");
childForm.ShowDialog(this);
}
}
public partial class ChildForm : Form
{
public ChildForm(string message)
{
InitializeComponent();
lblMessage.Text = message;
}
}
In this example, button1_Click
event in the ParentForm
creates a new instance of ChildForm
, passing a message string to it. ChildForm
then displays this message in a label (lblMessage
).
Reference
The content in this document is based on the original notes provided in Azerbaijani. For further details, you can refer to the original document using the following link:
Original Note - Azerbaijani Version