In this example, we’ll learn how to change the item fontstyle inside the listbox item using FontDialog control.
Form Design:
Source Code:
Add Button:
1 2 3 4 5 6 | private void button1_Click(object sender, EventArgs e) { lstName.Items.Add(txtName.Text); } |
Change ListBox Font Button:
1 2 3 4 5 6 7 8 9 | private void button2_Click(object sender, EventArgs e) { if(fontDialog1.ShowDialog()==DialogResult.OK) { lstName.Font = fontDialog1.Font; } } |
When the above code is set, and the project is executed using Visual Studio, you will get the below output.