c# - Retrieving selected checkedlistbox -


I'm still learning C # and winform and I can not seem to fix my problem. The problem is that whenever I select the item in my SQL generated checklist box and press the button 2 event, it will not show the actual data, it just shows "System.Data.DataRowView", I am forgetting some code here ..

  Private Zero Button 2_Click (Object Sender, EventArgs e) {int counter = checkedListBox1. Selected Its. Count; & Lt; String & gt; Selectitems = new list & lt; String & gt; (); (Int i = 0; i & lt; counter; i ++) {selectitems.Add (checklistbox 1. selected item [i] .toString ()); MessageBox.Show (the selected [0]);  

Here is the code for the generation of checklist boxes.

  con.Open (); SqlCommand CMD = New SQL Commands ("Choose * to tbl_members ORDER BY status", Con?); SqlDataAdapter Adapter = New SqlDataAdapter (CMD); SqlDataReader Reader = cmd.ExecuteReader (); Datatable dt = new datatable (); Dt.Columns.Add ("full name", typef (string)); Dt.load (reader); Dataset ds = new dataset (); Adapter.fill (ds); Checklistbox 1 Data source = databables [0]; Checklist Button 1 Displaymilk = "full name"; Checklist Button 1 Value = "full name"; CheckedListBox1.Enabled = true; CheckedListBox1.Refresh (); Count = Convert.ToInt32 (numericUpDown1.Value); Con.Close ();     

for your loop in button2_Click Try changing:

foreach (see line row in checked listboxes) {selectitems.Add (line view ["fullname"]. ToString ()); }

Comments