Click here to Skip to main content
15,891,431 members
Home / Discussions / C#
   

C#

 
QuestionDatabinding Exception in my UserControl Pin
User 20930732-Sep-05 2:50
User 20930732-Sep-05 2:50 
QuestionVoice Communication in C# Pin
Zeeshan Gulzar2-Sep-05 1:40
Zeeshan Gulzar2-Sep-05 1:40 
AnswerRe: Voice Communication in C# Pin
Judah Gabriel Himango2-Sep-05 4:57
sponsorJudah Gabriel Himango2-Sep-05 4:57 
GeneralRe: Voice Communication in C# Pin
Zeeshan Gulzar2-Sep-05 22:45
Zeeshan Gulzar2-Sep-05 22:45 
GeneralRe: Voice Communication in C# Pin
Judah Gabriel Himango3-Sep-05 12:29
sponsorJudah Gabriel Himango3-Sep-05 12:29 
QuestionCombobox Items Pin
PHDENG812-Sep-05 1:27
PHDENG812-Sep-05 1:27 
AnswerRe: Combobox Items Updated Pin
PHDENG812-Sep-05 2:02
PHDENG812-Sep-05 2:02 
AnswerRe: Combobox Items Pin
Dario Solera2-Sep-05 2:10
Dario Solera2-Sep-05 2:10 
You can create a custom class redefining the ToString() method.
The ComboBox uses the ToString() method to retrieve a string to display in the UI for each item.

C#
<br />
class MyItem {<br />
<br />
private string name; // String to show in the ComboBox<br />
private string val; // String to show in the TextBox<br />
<br />
public MyItem(string n, string v) {<br />
name = n;<br />
   val = v;<br />
}<br />
<br />
public string ToString() {<br />
   return name;<br />
}<br />
<br />
public string Content {<br />
   get {<br />
      return val;<br />
   }<br />
}<br />
<br />
}<br />
<br />
ComboBox c = new ComboBox();<br />
c.Items.Add(new MyItem("good", "User choosed good"));<br />
<br />
// Remember to perform the correct casts.<br />
<br />
ComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {<br />
   textBox.Text = ((MyItem)c.SelectedItem).Content;<br />
}<br />

I hope



[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
GeneralRe: Combobox Items Pin
PHDENG812-Sep-05 2:28
PHDENG812-Sep-05 2:28 
GeneralRe: Combobox Items Pin
PHDENG812-Sep-05 2:38
PHDENG812-Sep-05 2:38 
GeneralRe: Combobox Items Pin
PHDENG812-Sep-05 2:50
PHDENG812-Sep-05 2:50 
GeneralRe: Combobox Items Pin
miah alom2-Sep-05 4:39
miah alom2-Sep-05 4:39 
GeneralRe: Combobox Items Pin
Dario Solera2-Sep-05 8:46
Dario Solera2-Sep-05 8:46 
QuestionInternet Timer Pin
Illegal Operation2-Sep-05 1:21
Illegal Operation2-Sep-05 1:21 
AnswerRe: Internet Timer Pin
Judah Gabriel Himango3-Sep-05 12:34
sponsorJudah Gabriel Himango3-Sep-05 12:34 
QuestionHow to make tow forms in the same layer? Pin
dreamwinter1-Sep-05 23:27
dreamwinter1-Sep-05 23:27 
AnswerRe: How to make tow forms in the same layer? Pin
Dario Solera2-Sep-05 1:54
Dario Solera2-Sep-05 1:54 
QuestionHow about DataCloumn.Expression Pin
Libra1-Sep-05 23:00
Libra1-Sep-05 23:00 
Questiongraphic control question c# Pin
fady_sayegh1-Sep-05 22:27
fady_sayegh1-Sep-05 22:27 
AnswerRe: graphic control question c# Pin
Stanciu Vlad2-Sep-05 0:38
Stanciu Vlad2-Sep-05 0:38 
QuestionHow to save MailMessage object Pin
jdkulkarni1-Sep-05 21:54
jdkulkarni1-Sep-05 21:54 
QuestionHow to Display .Msg format file in C# Pin
pradyumna jaganmohan1-Sep-05 21:44
pradyumna jaganmohan1-Sep-05 21:44 
QuestionHow to write a statement in several line? Pin
rushing1-Sep-05 21:22
rushing1-Sep-05 21:22 
AnswerRe: How to write a statement in several line? Pin
esjq1-Sep-05 22:06
esjq1-Sep-05 22:06 
GeneralRe: How to write a statement in several line? Pin
miah alom2-Sep-05 4:40
miah alom2-Sep-05 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.