I have a listview control where i added some column headers. Now the query is when i select any text on the textbox i want to import on listview control under the specific column header. ????

Currently its adding any selected text from textbox to listview control but under the first column header. e.g.

// Column Header Code

private void Form1_Load(object sender, EventArgs e)
            ListView scheduleListView=new ListView();
            scheduleListView.View = View.Details;
            colheader1 = new ColumnHeader();
            colheader1.Text = "Schedule Name";
            colheader1.Width = 100;
            colheader2 = new ColumnHeader();
            colheader2.Text = "File Name";
            colheader2.Width = 100;
            colheader3 = new ColumnHeader();
            colheader3.Text = "Start Time";
            colheader3.Width = 100;
            colheader4 = new ColumnHeader();
            colheader4.Text = "End Time";
            colheader4.Width = 100;
            scheduleListView.Sorting = SortOrder.Ascending;
            scheduleListView.GridLines = true;


// When button is clicked it should import the filename under file name column header?

private void addBtn_Click(object sender, EventArgs e)
ListViewItem lvt = new ListViewItem();
lvt = scheduleListView.Items.Add(textFile.Text);

Thanks. Please Advise

I found the solution as I just needed to put string array in ListViewItem declaration.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.