/// /////////////////////////////////////////////////////// /// <summary> /// Passe la cellule en édition grâce au contrôle correspondant /// </summary> protected override void Edit( CurrencyManager cur, int nLigne, Rectangle bounds, bool bReadOnly, string strValue, bool bCellIsVisible) { CChampCustom champ = ((CChampCustom)m_listeChamps[nLigne]); if (champ.ListeValeurs.Count == 0) { m_control = GetControl(champ.TypeDonneeChamp.TypeDonnee, champ.Precision, champ.Nom); } else { m_control = m_combobox; m_combobox.Items.Clear(); foreach (CValeurChampCustom valeur in ((CChampCustom)m_listeChamps[nLigne]).ListeValeurs) { m_combobox.Items.Add(valeur.Display); } } if (m_control == null) { return; } if (this.DataGridTableStyle.DataGrid.ReadOnly) { m_control.Hide(); return; } m_bEnEdition = true; if (strValue == null) { strValue = GetValeurColumn(cur, nLigne).ToString(); } if (champ.ListeValeurs.Count > 0) { strValue = champ.DisplayFromValue(strValue); } m_control.Parent = this.DataGridTableStyle.DataGrid; m_control.Bounds = bounds; m_control.Show(); SetValeurControl(m_control, strValue); m_control.Focus(); //Définit le controle qui doit éditer la valeur de la cellule ColumnStartedEditing(m_control); }
protected override void Paint( Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight ) { CChampCustom champ = ((CChampCustom)m_listeChamps[rowNum]); String strValeur = GetColumnValueAtRow(source, rowNum).ToString(); if (champ.ListeValeurs.Count > 0) { strValeur = champ.DisplayFromValue(strValeur); } if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tBool) { strValeur = strValeur.ToLower() == "true"?"Oui":"Non"; } SolidBrush brush; if (m_bIsErreur[rowNum]) { brush = new SolidBrush(Color.LightPink); } else { brush = new SolidBrush(this.DataGridTableStyle.DataGrid.BackColor); } g.FillRectangle(brush, bounds); brush.Dispose(); Font laFont = new Font(this.DataGridTableStyle.DataGrid.Font, FontStyle.Regular); SizeF size = g.MeasureString(strValeur, laFont); Rectangle rectToDraw = bounds; StringFormat sf = new StringFormat(); brush = new SolidBrush(this.DataGridTableStyle.DataGrid.ForeColor); g.DrawString( strValeur, laFont, brush, bounds, sf); laFont.Dispose(); brush.Dispose(); }
public CTodoValeurChamp(DataSet ds, IObjetDonneeAChamps obj, CChampTimosWebApp champWeb, int nIdGroupeAssocie, bool bIsEditable) { DataTable dt = ds.Tables[c_nomTable]; if (dt == null) { return; } DataRow row = dt.NewRow(); int nIdChampWeb = champWeb.Id; int nIdChampTimos = champWeb.IdTimos; string strLibelleWeb = champWeb.WebLabel; int nOrdreWeb = champWeb.WebNumOrder; string strValeur = ""; string strElementType = ""; int nElementId = -1; CChampCustom champ = champWeb.Champ; bool bAutoComplete = champWeb.UseAutoComplete; if (champ != null) { if (obj != null) { strElementType = obj.GetType().ToString(); nElementId = ((IObjetDonneeAIdNumerique)obj).Id; m_valeur = CUtilElementAChamps.GetValeurChamp(obj, nIdChampTimos); if (m_valeur != null) { if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tObjetDonneeAIdNumeriqueAuto) { IObjetDonneeAIdNumerique objetValeur = m_valeur as IObjetDonneeAIdNumerique; if (objetValeur != null) { try { if (bIsEditable && !bAutoComplete) { strValeur = objetValeur.Id.ToString(); } else { strValeur = objetValeur.DescriptionElement; } } catch { strValeur = ""; } } } else if (champ.IsChoixParmis()) { try { if (bIsEditable) { strValeur = m_valeur.ToString(); } else { strValeur = champ.DisplayFromValue(m_valeur); } } catch { strValeur = ""; } } else { try { strValeur = m_valeur.ToString(); } catch { strValeur = ""; } } } } } else { C2iExpression formule = champWeb.Formule; if (formule != null) { CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(obj); CResultAErreur resFormule = formule.Eval(ctx); if (resFormule && resFormule.Data != null) { strValeur = resFormule.Data.ToString(); } } } row[c_champId] = nIdChampWeb; row[c_champLibelle] = strLibelleWeb; row[c_champOrdreAffichage] = nOrdreWeb; row[c_champValeur] = strValeur; row[c_champElementType] = strElementType; row[c_champElementId] = nElementId; row[c_champIdGroupeChamps] = nIdGroupeAssocie; row[c_champUseAutoComplete] = champWeb.UseAutoComplete; m_row = row; dt.Rows.Add(row); }
protected override void Edit( CurrencyManager cur, int nLigne, Rectangle bounds, bool bReadOnly, string strValue, bool bCellIsVisible) { if (m_control != null) { m_control.Visible = false; } if (strValue == null) { strValue = GetColumnValueAtRow(cur, nLigne).ToString(); } CChampCustom champ = ((CChampCustom)m_listeChamps[nLigne]); if (champ.ListeValeurs.Count > 0) { strValue = champ.DisplayFromValue(strValue); } if (champ.ListeValeurs.Count == 0) { if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tString) { //Champ libre m_control = m_textbox; m_textbox.MaxLength = 1024; } else if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tDate) { m_control = m_datetimePicker; } else if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tEntier) { m_control = m_textBoxNumeric; m_textBoxNumeric.DecimalAutorise = false;; } else if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tDouble) { m_control = m_textBoxNumeric; m_textBoxNumeric.DecimalAutorise = false; } else if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tBool) { m_control = m_checkBox; m_checkBox.Text = champ.Nom; } } else { m_control = m_combobox; m_combobox.Items.Clear(); foreach (CValeurChampCustom valeur in ((CChampCustom)m_listeChamps[nLigne]).ListeValeurs) { m_combobox.Items.Add(valeur.Display); } } if (m_control == null) { return; } m_control.Name = m_control.GetType().ToString() + "_ChpCustom"; m_control.Parent = this.DataGridTableStyle.DataGrid; m_control.Bounds = bounds; SetValeurControl(m_control, strValue); if (bCellIsVisible && !this.DataGridTableStyle.DataGrid.ReadOnly) { m_control.BringToFront(); m_control.Show(); m_control.Focus(); } else { m_control.Hide(); } ColumnStartedEditing(m_control); }