How to add a list of strings to ListBox using WinForms in C#

1 Answer

0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var list = new List<string>() { "c#", "java", "c++", "c", "python" };

            listBox1.DataSource = list;
        }
    }
}




/*
 * run:
 *
 * 
 * 
 */


 



answered Aug 16, 2023 by avibootz

Related questions

1 answer 139 views
1 answer 128 views
1 answer 128 views
1 answer 145 views
1 answer 138 views
1 answer 166 views
...