Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

windows forms data controls and databinding

$
0
0

i'm trying to add list data object with list control two time.

1)first click on button when in list box there is no items [if block content]

2)second click onwards [else bock content]

problem is on second click data loading in list data object successfully but not displayed in list box.

public partial class Form11 : Form
    {

        List<string> str = new List<string>();

        public Form11()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (listBox1.Items.Count == 0)
            {
                str.Add("A");
                str.Add("B");
            }
            else
            {
                str.Add("C");
            }
            listBox1.DataSource = str;
        }
    }


            

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>