Before this question, I asked the question on this site. (Mr. John Skeet answered!)
I'm having trouble retrieving SelectedItem
's CheckedListBox
. Please see my code:
public class StaticValues {Private string value; Private string display; Public Static Value (String Val, String Disp) {this.value = val; This.display = disp; } Public string value {get {return value; }} Public string display {get {return display; }}} Private Zero Form 3_load (Object Sender, EventAurge E) {ArrayList dataSource = new ArrayList (); DataSource.Add (new static value ("001", "item 1")); DataSource.Add (new static value ("002", "Item 2")); DataSource.Add (new static value ("003", "Item 3")); CheckedListBox1.DataSource = DataSource; Checklist Button 1 Displaymilk = "display"; Checklist Button 1 Value = "value"; } Private Zero Button 1_Click (Object Sender, EventArgs e) {MessageBox.Show (checkedListBox1.SelectedValue.ToString ()); // Reset the selected value message box to the output (checklist box 1. Selected ITem.ToString ()); // This is not a selected item
How do I get selected item
Given that this is a list of check boxes, I suspect that it would be better to find items checked using the property all from there , You can get different items and get reasonable prices from that. While DisplayMember
works, I suspect that you are better than casting items for a known type and searching the value in that way, unless it is really strange for you. This may be another way, but I do not know about one, note that the docs claim that this "is not relevant to this class".
Comments
Post a Comment