Friday, August 9, 2024

Winform -Data Binding to a List

Create a form that displays a list of names in a `ListBox`. Populate the `ListBox` with some sample data when the form loads.


1. Add a `ListBox` to the form.
2. In the form’s `Load` event, populate the `ListBox` with data.

```csharp
private void Form1_Load(object sender, EventArgs e)
{
    List<string> names = new List<string> { "Alice", "Bob", "Charlie" };
    listBox1.DataSource = names;
}

No comments:

Your Title