//----------------------------------------------------------------------- public static CInfoChampDynamique[] SelectProprietes(CInfoStructureDynamique structure, string[] listeSelectionnes, ref CInfoChampDynamique[] lstDecoches) { CFormSelectChampParentPourStructure form = new CFormSelectChampParentPourStructure(); form.m_tableSelectionnes.Clear(); foreach (string strCol in listeSelectionnes) { form.m_tableSelectionnes[strCol] = true; } form.m_structurePrincipale = structure; form.m_lblTable.Text = form.m_structurePrincipale.NomConvivial; form.FillTree(structure, form.m_arbre.Nodes, null); form.m_arbre.CheckBoxes = true; form.m_bMonoSelection = false; if (form.ShowDialog() == DialogResult.OK) { ArrayList lst = new ArrayList(); form.GetSelectedFields(lst, form.m_arbre.Nodes, null); lstDecoches = (CInfoChampDynamique[])form.m_listeDecoches.ToArray(typeof(CInfoChampDynamique)); //Lst contient la liste de ce qui a été coché en plus. Il faut ajouter à ça la //Liste de ce qui n'a pas été décoché return(( CInfoChampDynamique[] )lst.ToArray(typeof(CInfoChampDynamique))); } return(new CInfoChampDynamique[0]); }
//------------------------------------------------------------------- private void OnSelectionnerLesChamps(object sender, EventArgs args) { ArrayList lst = new ArrayList(); Hashtable tableAvant = new Hashtable(); foreach (ListViewAutoFilledColumn col in Colonnes) { lst.Add(col.Field); tableAvant[col.Field] = col; } CInfoChampDynamique [] lstDecoches = null; CInfoChampDynamique[] champs = CFormSelectChampParentPourStructure.SelectProprietes(m_structureObjets, (string[])lst.ToArray(typeof(string)), ref lstDecoches); if (champs == null || champs.Length == 0) { return; } foreach (CInfoChampDynamique infoChamp in champs) { string strChamp = infoChamp.NomPropriete; if (tableAvant[strChamp] == null) { ListViewAutoFilledColumn col = new ListViewAutoFilledColumn(); col.Field = strChamp; col.Visible = true; col.Text = infoChamp.NomChamp; if (typeof(double).IsAssignableFrom(infoChamp.TypeDonnee)) { col.TextAlign = HorizontalAlignment.Right; } Colonnes.Add(col); FillColonne(col); } tableAvant.Remove(strChamp); } if (lstDecoches != null) { foreach (CInfoChampDynamique champ in lstDecoches) { foreach (ListViewAutoFilledColumn oldCol in tableAvant.Values) { if (oldCol.Field == champ.NomChamp) { RemoveColonne(oldCol); break; } } } } }
//----------------------------------------------------------------------- public static CInfoChampDynamique SelectPropriete(CInfoStructureDynamique structure) { CFormSelectChampParentPourStructure form = new CFormSelectChampParentPourStructure(); form.m_tableSelectionnes.Clear(); form.m_structurePrincipale = structure; form.m_lblTable.Text = form.m_structurePrincipale.NomConvivial; form.FillTree(structure, form.m_arbre.Nodes, null); form.m_arbre.CheckBoxes = false; form.m_bMonoSelection = true; CInfoChampDynamique infoSel = null; if (form.ShowDialog() == DialogResult.OK) { infoSel = form.m_champSel; } form.Dispose(); return(infoSel); }