salve a tutti
ho bisogno di una combobox con piu colonne, in fase di caricamento ci sono riuscito, peccato che è dopo che seleziono che non mi visualizza nel form quello selezionato
questo è il codice di selectedindexchanged()
cosa sbaglio?
-DTcentri è un datatable già pieno, riempito nella generale quindi visibile
in pratica gli dico di fare il drawstring eanche il drawline per la divisione in colonne, ma non vedo nulla, non compare nulla sullo schermo UFF
codice:private void CentriComboBox_SelectedIndexChanged(object sender, EventArgs e) { int indice = CentriComboBox.SelectedIndex; DataRow r = null; if (indice < DTcentri.Rows.Count) { r = DTcentri.Rows[indice]; } else { return; } System.Drawing.Graphics formGraphics = CentriComboBox.CreateGraphics();// this.CreateGraphics(); string Nome = r["Nome"].ToString(); string District = string.IsNullOrEmpty(r["District"].ToString()) ? "" : r["District"].ToString(); string Min_Code = string.IsNullOrEmpty(r["Min_Code"].ToString()) ? "" : r["Min_Code"].ToString(); string Provincia = string.IsNullOrEmpty(r["Provincia"].ToString()) ? "" : r["Provincia"].ToString(); int Colonne = 5;//2 colonne da impostare la combo int[] Column = new int[4]; int[] width = new int[4]; int L = CentriComboBox.Bounds.Width / Colonne;//larghezzaNormale Column[0] = L; Column[1] = Column[0] + L;// Column[0]; Column[2] = Column[0] + Column[1];// Column[0] + Column[1]-20; Column[3] = Column[0] + Column[1] + L;// Column[0] + Column[1] + Column[2]; width[0] = 200; width[1] = 70; width[2] = 70; width[3] = 70; // Get the bounds for the first column Rectangle r1 = CentriComboBox.Bounds; r1.Width = width[0];//= Colonne; // Draw the text on the first column using (SolidBrush sb = new SolidBrush(CentriComboBox.ForeColor)) formGraphics.DrawString(Nome, CentriComboBox.Font, sb, r1); using (Pen p = new Pen(Color.Black)) formGraphics.DrawLine(p, r1.Right, 0, r1.Right, r1.Bottom); // Get the bounds for the second column Rectangle r2 = CentriComboBox.Bounds; r2.X = Column[1];// args.Bounds.Width / Colonne; r2.Width = width[1];///= Colonne; // Draw the text on the second column using (SolidBrush sb = new SolidBrush(CentriComboBox.ForeColor)) formGraphics.DrawString(Min_Code, CentriComboBox.Font, sb, r2); }

Rispondi quotando