private void listKategorie_SelectedIndexChanged(object sender, EventArgs e) { global global = new global(); listWort.Items.Clear(); ListView.SelectedListViewItemCollection testColl2 = new ListView.SelectedListViewItemCollection(listKategorie); testColl2 = listKategorie.SelectedItems; if (testColl2.Count > 0) { string siItem2 = testColl2[0] /*.SubItems[0]*/.Text; int tablesCounterW = global.datasetWort.Tables[global.datasetWort.Tables[0].TableName].Columns.Count; for (int i = 0; i < tablesCounterW; i++) { if (global.datasetWort.Tables[global.datasetWort.Tables[0].TableName].Rows[i]["Kategorie"].ToString() == siItem2) { ListViewItem lviWort = new ListViewItem(global.datasetWort.Tables[global.datasetWort.Tables[0].TableName].Rows[i]["ID"].ToString()); lviWort.SubItems.Add((String)global.datasetWort.Tables[global.datasetWort.Tables[0].TableName].Rows[i]["BEZ"]); listWort.Items.Add(lviWort); } } //listWort.Items[0].Focused = true; listWort.Items[0].Selected = true; listWort.Select(); } else { ListViewItem lviWort = new ListViewItem("!!!"); lviWort.SubItems.Add("SelectedListViewItemCollection = null!!"); listWort.Items.Add(lviWort); } }
private void tabWort_Enter(object sender, EventArgs e) { global global = new global(); //--------------Einlesen der Themen aus der DB listThema.Items.Clear(); int tablesCounterT = global.datasetThema.Tables.Count; try { tablesCounterT = global.datasetThema.Tables[global.datasetThema.Tables[0].TableName].Columns.Count; } catch (Exception ex) { string fehler = ex.ToString(); } for (int i = 0; i < tablesCounterT; i++) { ListViewItem lviThema = new ListViewItem(global.datasetThema.Tables[global.datasetThema.Tables[0].TableName].Rows[i]["ID"].ToString()); lviThema.SubItems.Add((String)global.datasetThema.Tables[global.datasetThema.Tables[0].TableName].Rows[i]["BEZ"]); listThema.Items.Add(lviThema); } if (listThema.Items.Count > 0) { listThema.Items[0].Focused = true; listThema.Items[0].Selected = true; listThema.Select(); } else { int count = listThema.Items.Count; } }
private void listThema_SelectedIndexChanged(object sender, EventArgs e) { global global = new global(); //Rund 1: Thema = 1; Kategorie = ok / Runde 2: Thema = 2; Kategorie = ko / Runde 3: Thema = ko --> häääää???????????????????? --> TODO!!!!!!!!! listKategorie.Items.Clear(); ListView.SelectedListViewItemCollection testColl = new ListView.SelectedListViewItemCollection(listThema); //string dsKat = datasetKategorie.Tables[datasetKategorie.Tables[0].TableName].Rows[0]["Thema"].ToString(); testColl = listThema.SelectedItems; if (testColl.Count == 0) //test { listThema.Items[1].Selected = true; listThema.Select(); } if (testColl.Count > 0) { testColl = listThema.SelectedItems; string siItem = testColl[0] /*.SubItems[0]*/.Text; int tablesCounterK = global.datasetKategorie.Tables[global.datasetKategorie.Tables[0].TableName].Columns.Count; for (int i = 0; i < tablesCounterK; i++) { if (global.datasetKategorie.Tables[global.datasetKategorie.Tables[0].TableName].Rows[i]["Thema"].ToString() == siItem) { ListViewItem lviKategorie = new ListViewItem(global.datasetKategorie.Tables[global.datasetKategorie.Tables[0].TableName].Rows[i]["ID"].ToString()); lviKategorie.SubItems.Add((String)global.datasetKategorie.Tables[global.datasetKategorie.Tables[0].TableName].Rows[i]["BEZ"]); listKategorie.Items.Add(lviKategorie); } } int katCount = listKategorie.Items.Count; if (katCount > 0) { listThema.Items[0].Selected = true; //test listKategorie.Items[0].Focused = true; listKategorie.Items[0].Selected = true; listKategorie.Select(); } } else { ListViewItem lviKategorie = new ListViewItem("!!!"); lviKategorie.SubItems.Add("SelectedListViewItemCollection = null!!"); listKategorie.Items.Add(lviKategorie); } }
public void Load() { global global = new global(); //--------------Verbinden und Öffnen der DB SQLiteConnection connection = new SQLiteConnection(); connection.ConnectionString = "Data Source = " + global.dbPfad; connection.Open(); //-------------Einlesen der Themen aus der DB string commandThema = "SELECT * FROM Thema"; SQLiteCommand SqlcmdT = new SQLiteCommand(); SqlcmdT.CommandType = System.Data.CommandType.Text; SqlcmdT.CommandText = commandThema; SqlcmdT.Connection = connection; SQLiteDataAdapter dataAdapterT = new SQLiteDataAdapter(SqlcmdT); dataAdapterT.FillSchema(global.datasetThema, SchemaType.Source); dataAdapterT.Fill(global.datasetThema); //--------------Einlesen der Kategorien aus der DB string commandKat = "SELECT * FROM Kategorie"; SQLiteCommand SqlcmdK = new SQLiteCommand(); SqlcmdK.CommandType = System.Data.CommandType.Text; SqlcmdK.CommandText = commandKat; SqlcmdK.Connection = connection; SQLiteDataAdapter dataAdapterK = new SQLiteDataAdapter(SqlcmdK); dataAdapterK.Fill(global.datasetKategorie); //---------------Einlesen der Wörter aus der DB string commandW = "SELECT * FROM Wort"; SQLiteCommand SqlcmdW = new SQLiteCommand(); SqlcmdW.CommandType = System.Data.CommandType.Text; SqlcmdW.CommandText = commandW; SqlcmdW.Connection = connection; SQLiteDataAdapter dataAdapterW = new SQLiteDataAdapter(SqlcmdW); dataAdapterW.Fill(global.datasetWort); //---------------Einlesen der Favoriten aus der DB string commandF = "SELECT * FROM Favorit"; SQLiteCommand SqlcmdF = new SQLiteCommand(); SqlcmdW.CommandType = System.Data.CommandType.Text; SqlcmdW.CommandText = commandW; SqlcmdW.Connection = connection; SQLiteDataAdapter dataAdapterF = new SQLiteDataAdapter(SqlcmdW); dataAdapterW.Fill(global.datasetFavorit); //---------------Einlesen der Listen aus der DB string commandL = "SELECT * FROM Liste"; SQLiteCommand SqlcmdL = new SQLiteCommand(); SqlcmdW.CommandType = System.Data.CommandType.Text; SqlcmdW.CommandText = commandW; SqlcmdW.Connection = connection; SQLiteDataAdapter dataAdapterL = new SQLiteDataAdapter(SqlcmdW); dataAdapterW.Fill(global.datasetListe); //---------------Schließen der DB-Verbingung connection.Close(); }