Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

hallo forum,

folgendes problem:

ich lese felder aus einer datenbank aus und schreibe in eine combobox:


			while (myReader.Read())

			{

				int course_id = myReader.GetInt32(0);

				string course_name = myReader.GetString(1);

				string course_description = myReader.GetString(2);


				tmp = new course(course_id, course_name, course_description);


				c_combobox.Items.Add(course_name);

				c_combobox.Items[c_combobox.Items.Count-1] = tmp.course_name;


			}

die combobox zeigt jetzt die course_namen an. nun möchte ich, sobald eine auswahl getroffen wird, ein textfeld neben der combobox mit der course_description füllen. wie funktioniert das in der folgenden methode:

	private void c_combobox_SelectedIndexChanged(object sender, System.EventArgs e)

		{

                  // ???


}
ich hab schon einiges versucht, habe aber immer probleme mit dem casten ... ich habe es so probiert:

		private void c_combobox_SelectedIndexChanged(object sender, System.EventArgs e)

		{

			course tmp = (course) c_combobox.SelectedItem;

			c_description.Text = tmp.course_description;


		}

und mit vielen anderen methoden ... ich bekomm das nicht hin ....

wer kann helfen??

danke!!

ist das casting bei der c_combobox_SelectedIndexChanged korrekt? weiss das jemand?

Jedenfalls steckst du bisher nur Strings (Namen) in die Combobox. Ich bezweifle, dass du dann course-Objekte wieder rausholen kannst.

du hast recht, stimmt.

hast du eine idee, wie ich das evtl. anders machen koennte?

hast du eine idee, wie ich das evtl. anders machen koennte?
Versuche nicht, ein UI-Element als Datencontainer zu missbrauchen. Lies die Daten in eine zusätzliche Liste ein, und benutz den Index des in der Combobox ausgewählten Elements als Index auf die Liste.

Für weitere Informationen wäre es sehr hilfreich, wenn du verrätst, um welche Sprache es sich da handelt.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.