// ========================================================================
    // Methods

    #region === Methods

    /// <summary>
    ///   Gets the formatted value of the cell's data.
    /// </summary>
    /// <returns>
    ///   The value.
    /// </returns>
    /// <param name = "value">The value to be formatted. </param>
    /// <param name = "rowIndex">The index of the cell's parent row. </param>
    /// <param name = "cellStyle">The <see cref = "T:System.Windows.Forms.DataGridViewCellStyle" /> in effect for the cell.</param>
    /// <param name = "valueTypeConverter">A <see cref = "T:System.ComponentModel.TypeConverter" /> associated with the value type that provides custom conversion to the formatted value type, or null if no such custom conversion is needed.</param>
    /// <param name = "formattedValueTypeConverter">A <see cref = "T:System.ComponentModel.TypeConverter" /> associated with the formatted value type that provides custom conversion from the value type, or null if no such custom conversion is needed.</param>
    /// <param name = "context">A bitwise combination of <see cref = "T:System.Windows.Forms.DataGridViewDataErrorContexts" /> values describing the context in which the formatted value is needed.</param>
    /// <exception cref = "T:System.Exception">Formatting failed and either there is no handler for the <see cref = "E:System.Windows.Forms.DataGridView.DataError" /> event of the <see cref = "T:System.Windows.Forms.DataGridView" /> control or the handler set the <see cref = "P:System.Windows.Forms.DataGridViewDataErrorEventArgs.ThrowException" /> property to true. The exception object can typically be cast to type <see cref = "T:System.FormatException" /> for type conversion errors or to type <see cref = "T:System.ArgumentException" /> if <paramref name = "value" /> cannot be found in the <see cref = "P:System.Windows.Forms.DataGridViewComboBoxCell.DataSource" /> or the <see cref = "P:System.Windows.Forms.DataGridViewComboBoxCell.Items" /> collection. </exception>
    protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle,
                                                TypeConverter valueTypeConverter,
                                                TypeConverter formattedValueTypeConverter,
                                                DataGridViewDataErrorContexts context)
    {
      return value;
    }
        protected override object GetFormattedValue(object value,
           int rowIndex, ref DataGridViewCellStyle cellStyle,
           TypeConverter valueTypeConverter,
           TypeConverter formattedValueTypeConverter,
           DataGridViewDataErrorContexts context)
        {
            object returnVal = String.Empty;

            if (value != null)
            {
                if (value.GetType() == typeof(byte[]))
                    returnVal = BitConverter.ToString((byte[])value);
                else if (value.GetType() == typeof(byte))
                    returnVal = BitConverter.ToString(new byte[] { (byte)value });
                else if (value.GetType() == typeof(int))
                    returnVal = BitConverter.ToString(BitConverter.GetBytes(((int)value)),0);
                else if (value.GetType() == typeof(uint))
                    returnVal = BitConverter.ToString(BitConverter.GetBytes(((uint)value)), 0);
                else if (value.GetType() == typeof(short))
                    returnVal = BitConverter.ToString(BitConverter.GetBytes(((short)value)), 0);
                else if (value.GetType() == typeof(ushort))
                    returnVal = BitConverter.ToString(BitConverter.GetBytes(((ushort)value)), 0);
            }
            return returnVal;
        }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            Guid obj = (Guid) value;
            string val = PaymentController.GetInstance().GetCustomer(obj).ToString();

            return val;
        }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     isVisualStyled = VisualStyleInformation.IsEnabledByUser & VisualStyleInformation.IsSupportedByOS;
     if (value == null)
     {
         return emptyImage;
     }
     float percentage = (float)((int)value);
     if (percentage == 0)
         return emptyImage;
     else
     {
         contentGraphics.Clear(Color.Transparent);
         float drawedPercentage = percentage > 100 ? 100 : percentage;
         if (isVisualStyled)
         {
             bigProgressRect.Width = (int)(66 * drawedPercentage / 100.0f);
             ProgressBarRenderer.DrawHorizontalBar(contentGraphics, bigBorderRect);
             ProgressBarRenderer.DrawHorizontalChunks(contentGraphics, bigProgressRect);
         }
         else
         {
             progressRect.Width = (int)(66 * drawedPercentage / 100.0f);
             contentGraphics.DrawRectangle(blackPen, borderRect);
             contentGraphics.FillRectangle(lightGreenBrush, progressRect);
         }
         contentGraphics.DrawString(percentage.ToString("0.00") + "%", this.DataGridView.Font, foreColor, 10, 5);
     }
     return contentImage;
 }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            if (value == DBNull.Value || value == null)
                return "";

            return RealmSynergy.FromSeries((uint)value).Text;
        }
        protected override object GetFormattedValue(object value,
            int rowIndex, ref DataGridViewCellStyle cellStyle,
            TypeConverter valueTypeConverter,
            TypeConverter formattedValueTypeConverter,
            DataGridViewDataErrorContexts context)
        {
            if (value == null)
                value = 0;

            int progressVal = (int)value;

            if (progressVal > maxVal)
                progressVal = maxVal;
            if (progressVal < minVal)
                progressVal = minVal;

            Bitmap bmp = new Bitmap(OwningColumn.Width - margin, OwningRow.Height - margin);
            Bitmap bmptxt = new Bitmap(OwningColumn.Width, OwningRow.Height);

            pb.Height = bmp.Height;
            pb.Width = bmp.Width;

            pb.BackColor = System.Drawing.Color.Transparent;
            pb.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(100)), ((System.Byte)(201)), ((System.Byte)(201)), ((System.Byte)(201)));
            pb.StartColor = this.startColor;
            pb.EndColor = this.endColor;
            //pb.HighlightColor = System.Drawing.Color.Orange;
            pb.TabIndex = 0;

            pb.Value = progressVal;
            pb.Update();
            pb.Invalidate();

            lbl.AutoSize = false;
            lbl.TextAlign = ContentAlignment.MiddleCenter;
            lbl.Height = bmptxt.Height;
            lbl.Width = bmptxt.Width;

            if (!this.Selected)
            {
                lbl.ForeColor = cellStyle.ForeColor;
                lbl.BackColor = cellStyle.BackColor;
            }
            else
            {
                lbl.ForeColor = cellStyle.SelectionForeColor;
                lbl.BackColor = cellStyle.SelectionBackColor;
            }

            pb.DrawToBitmap(bmp, pb.ClientRectangle);

            lbl.Text = String.Format("{0}%", progressVal);
            lbl.Image = bmp;
            lbl.ImageAlign = ContentAlignment.MiddleCenter;
            lbl.DrawToBitmap(bmptxt, lbl.ClientRectangle);

            return bmptxt;
        }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value is Enum)
         return Culture.Get(value.ToString());
     else if (value != null)
         return value.ToString();
     else
         return "";
 }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle,
            TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter,
            DataGridViewDataErrorContexts context)
        {
            if (value is Enum)
                return GetDescription((Enum)value);

            return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
        }
 /// <include file='doc\DataGridViewDataErrorEventArgs.uex' path='docs/doc[@for="DataGridViewDataErrorEventArgs.DataGridViewDataErrorEventArgs"]/*' />
 public DataGridViewDataErrorEventArgs(Exception exception,
     int columnIndex,
     int rowIndex,
     DataGridViewDataErrorContexts context) : base(columnIndex, rowIndex)
 {
     Debug.Assert(rowIndex > -1);
     this.exception = exception;
     this.context = context;
 }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value == null)
     {
         value = string.Empty;
         return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
     }
     string format = ((DataGridViewTimeColumn)OwningColumn).Format;
     value = ((DateTime)value).ToString(format);
     return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
 }
      protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
      {
        var col = ((DataGridViewListColumn)this.OwningColumn);
        var idx = FindIndexByProp(col.ValueMember, value as string);
        if (idx >= 0)
        {
          var bs = (BindingSource)col.DataSource;
          return bs.GetItemProperties(null)[col.DisplayMember].GetValue(bs[idx]);
        }

        return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
      }
        ///// <summary>
        ///// マスクに一致しているか?していないか?
        ///// をチェックする際に利用するMaskedTextBox
        ///// </summary>
        //private static MaskedTextBox _mtb = new MaskedTextBox();

        /// <summary>編集コントロールで変更されたセルの値</summary>
        public object GetEditingControlFormattedValue(
            DataGridViewDataErrorContexts context)
        {
            //return this.Text;// 編集処理がある場合工夫が必要
            //System.Diagnostics.Debug.WriteLine("GetEditingControlFormattedValue");
            //System.Diagnostics.Debug.WriteLine("・DataGridViewDataErrorContexts:" + context.ToString());
            //System.Diagnostics.Debug.WriteLine("・this.Text:" + this.Text);
            
            if (context ==
                (DataGridViewDataErrorContexts.Formatting
                | DataGridViewDataErrorContexts.Display))
            {
                // 編集モードに入るとき
            }
            else if (context ==
                (DataGridViewDataErrorContexts.Parsing
                | DataGridViewDataErrorContexts.Commit))
            {
                // マウスで抜けた場合

                // 例外あり。
                if (this.Edited)
                {
                    // 下端でEnterで抜けた場合
                    this.PreValidate();
                    this.ReEdit();
                }
            }
            else if (context ==
                (DataGridViewDataErrorContexts.Parsing
                | DataGridViewDataErrorContexts.Commit
                | DataGridViewDataErrorContexts.CurrentCellChange))
            {
                // Tab、Enterで抜けた場合
                this.PreValidate(); 
                this.ReEdit();
            }
            else if (context ==
                (DataGridViewDataErrorContexts.Parsing
                | DataGridViewDataErrorContexts.Commit
                | DataGridViewDataErrorContexts.LeaveControl))
            {
                // 上端でShift + Tabで抜けた場合
                this.PreValidate();
                this.ReEdit();
            }
            else
            {
                // 不明
            }

            return this.Text;
        }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            int width = this.OwningColumn.Width - 4;
            int height = this.OwningRow.Height - 4;

            if (value == null || !(value is double))
            {
                if (_EmptyImage == null || width != _EmptyImage.Width || height != _EmptyImage.Height)
                {
                    _EmptyImage = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                }
                return _EmptyImage;
            }

            RectangleF rect = new RectangleF(0, 0, width, height);
            if (_ContentImage == null || _ContentImage.Width != width || _ContentImage.Height != height)
            {
                _ContentImage = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
            }
            using (Graphics g = Graphics.FromImage(_ContentImage))
            {
                //g.Clear(Color.Transparent);
                double num = (double)value;
                if (num < 0)
                {
                    num = 0;
                }
                if (num > 1)
                {
                    num = 1;
                }

                if (VisualStyleInformation.IsEnabledByUser & VisualStyleInformation.IsSupportedByOS)
                {
                    ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle(2, 2, width - 2, height - 2));
                    if (num != 0)
                    {
                        ProgressBarRenderer.DrawHorizontalChunks(g, new Rectangle(3, 3, (int)((width - 4) * num), height - 4));
                    }
                }
                else
                {
                    g.DrawRectangle(Pens.Black, 2, 2, width - 2, height - 2);
                    if (num != 0)
                    {
                        g.FillRectangle(Brushes.Blue, 3, 3, (int)((width - 4) * num), height - 4);
                    }
                }

                g.DrawString(num.ToString("p1"), base.DataGridView.Font, _ForeColor, rect, _StringFormat);
                return _ContentImage;
            }
        }
 protected override object GetFormattedValue(object value,
    int rowIndex, ref DataGridViewCellStyle cellStyle,
    TypeConverter valueTypeConverter,
    TypeConverter formattedValueTypeConverter,
    DataGridViewDataErrorContexts context)
 {
     if ((value != null) && (value != DBNull.Value))
     {
         if ((MessageDirection)value == MessageDirection.ClientToServer) return "SEND";
         else return "RECV";
     }
     else return String.Empty;
 }
Exemple #15
0
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value != null)
     {
         if (value.ToString().Trim() != string.Empty)
         {
             if (Items.IndexOf(value) == -1)
             {
                 Items.Add(value);
                 DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn)OwningColumn;
                 col.Items.Add(value);
             }
         }
     }
     return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
 }
        protected override object GetFormattedValue(object value, int rowIndex, 
          ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, 
        TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            if (value != null && value.ToString().Trim() != string.Empty)
             {
             if (Items.IndexOf(value) == -1)// 如果下拉框中不存在填入的值,则添加到下拉框中
              {
                // Items.Add(value);
                 // 添加到该列所有单元所绑定的下拉列表中
                 //DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn)OwningColumn;
                 //col.Items.Add(value);
             }
             }

              return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
        }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            JointDOF dof = (JointDOF)value;
            Type doftype = typeof(JointDOF.DofType);
            string tmp = "";
            if (dof != null)
            {
                tmp += Enum.GetName(doftype, dof.T1).Substring(0, 1) + " ";
                tmp += Enum.GetName(doftype, dof.T2).Substring(0, 1) + " ";
                tmp += Enum.GetName(doftype, dof.T3).Substring(0, 1) + " ";
                tmp += Enum.GetName(doftype, dof.R1).Substring(0, 1) + " ";
                tmp += Enum.GetName(doftype, dof.R2).Substring(0, 1) + " ";
                tmp += Enum.GetName(doftype, dof.R3).Substring(0, 1);
            }

            return tmp;
        }
Exemple #18
0
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
   if (value is Dictionary<string, object>)
   {
     var ann = (Dictionary<string, object>)value;
     if (ann.ContainsKey(Key))
     {
       return base.GetFormattedValue(ann[Key].ToString(), rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
     }
     else
     {
       return string.Empty;
     }
   }
   else
   {
     return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
   }
 }
Exemple #19
0
      protected override object GetFormattedValue(object value,
         int rowIndex, ref DataGridViewCellStyle cellStyle,
         TypeConverter valueTypeConverter,
         TypeConverter formattedValueTypeConverter,
         DataGridViewDataErrorContexts context)
      {

         string resource = "CustomColumnAndCell.Red.bmp";
         StatusImage status = StatusImage.Red;
         // Try to get the default value from the containing column
         ContactsListColumn owningCol = OwningColumn as ContactsListColumn;
         if (owningCol != null)
         {
            status = owningCol.DefaultStatus;
         }
         if (value is StatusImage || value is int)
         {
            status = (StatusImage)value;
         }
         switch (status)
         {
            case StatusImage.Green:
                resource = "RemwaveClient.Resources.ContactBlank.png";
               break;            
             case StatusImage.Yellow:
                 resource = "RemwaveClient.Resources.ContactBlank.png";
               break;
            case StatusImage.Red:
                resource = "RemwaveClient.Resources.ContactBlank.png";
               break;
            default:
               break;
         }
         Assembly loadedAssembly = Assembly.GetExecutingAssembly();
         string[] mylist  = loadedAssembly.GetManifestResourceNames();

         Stream stream =
            loadedAssembly.GetManifestResourceStream(resource);
         Image img = Image.FromStream(stream);
         cellStyle.Alignment =
            DataGridViewContentAlignment.TopCenter;
         return img;
      }
        protected override object GetFormattedValue(
            object value,
            int rowIndex,
            ref DataGridViewCellStyle cellStyle,
            TypeConverter valueTypeConverter,
            TypeConverter formattedValueTypeConverter,
            DataGridViewDataErrorContexts context)
        {
            if (value == null)
                return null;
            int iValue;
            if (Int32.TryParse(value.ToString(), out iValue))
                if (iValue == CashedValue)
                    return CashedFormattedValue;

            var col = OwningColumn as DataGridViewDictionaryColumn;
            var CurrBS = col.DataSource as BindingSource;
            if (CurrBS == null)
                return null;
            var bs = new BindingSource()
                         {
                             DataSource = CurrBS.DataSource,
                             DataMember = CurrBS.DataMember,
                             Sort = CurrBS.Sort,
                             Filter = CurrBS.Filter
                         };
            var iPos = bs.Find(col.ValueMember, value);
            if (iPos<0)
                return null;
            bs.Position = iPos;
            var row = (bs.Current as DataRowView).Row;
            var sValue = String.IsNullOrEmpty(col.DescriptionMember)
                             ? String.Format(col.Format, row[col.DisplayMember])
                             : String.Format(col.Format, row[col.DisplayMember], row[col.DescriptionMember]);
            if (Int32.TryParse(value.ToString(), out iValue))
            {
                CashedValue = iValue;
                CashedFormattedValue = sValue;
            }
            return sValue;
        }
        //protected override object GetValue(int rowIndex)
        //{
        //    object value = base.GetValue(rowIndex);
        //    //if (value != null)
        //    //    return string.Format("{0:G5}", value);
        //    //return "";
        //    return value;
        //}
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            if (value != null)
            {
                //bool noFormatting = true;
                //try
                //{
                //    noFormatting = IsInEditMode;
                //}
                //catch (InvalidOperationException)
                //{
                //    noFormatting = true;
                //}

                //if (noFormatting)
                //    return ((float)value).ToString("G");// string.Format("{0:G}", value);
                //else
                    return ((float)value).ToString("F3"); //return string.Format("{0:F}", value);
            }

            return "";
        }
            protected override object GetFormattedValue(object value, int rowIndex,	ref DataGridViewCellStyle cellStyle, 
				TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
            {
                Bitmap bmp = new Bitmap(this.Size.Width, this.Size.Height);
                Rectangle rc = Rectangle.Empty;
                rc.Size = bmp.Size;

                Color clrOne = Color.LightBlue;
                Color clrTwo = Color.Navy;

                using (Graphics gfx = Graphics.FromImage(bmp))
                using (Brush b = new LinearGradientBrush(rc, clrOne, clrTwo, LinearGradientMode.Vertical)) {
                    gfx.Clear(Color.White);
                    // Percentage.
                    int percentage = 0;

                    if (this.Value != null)
                        int.TryParse(this.Value.ToString(), out percentage);
                    string text = percentage.ToString() + "%";

                    // Get width and height of text.
                    Font font = new Font("Tahoma", 10, FontStyle.Regular);
                    int width = (int)gfx.MeasureString(text, font).Width;
                    int height = (int)gfx.MeasureString(text, font).Height;

                    // Draw pile.
                    gfx.DrawRectangle(Pens.Black, 2, 2, this.Size.Width - 9, this.Size.Height - 6);
                    gfx.FillRectangle(b, 3, 3, (int)(this.Size.Width - 10) * percentage / 100, (int)this.Size.Height - 7);

                    RectangleF rect = new RectangleF(0, 0, bmp.Width, bmp.Height);
                    StringFormat sf = new StringFormat();
                    sf.Alignment = StringAlignment.Center;
                    gfx.DrawString(text, font, Brushes.Black, rect, sf);
                }
                return bmp;
            }
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(this.Value.ToLongTimeString());
 }
Exemple #24
0
 public DataGridViewDataErrorEventArgs(Exception exception, int columnIndex, int rowIndex, DataGridViewDataErrorContexts context) : base(columnIndex, rowIndex)
 {
     this.exception      = exception;
     this.context        = context;
     this.throwException = false;
 }
 /// <summary>
 /// Returns the current value of the editing control.
 /// </summary>
 public virtual object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(this.Text);
 }
Exemple #26
0
    protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
    {
        if (value != null)
        {
            System.Diagnostics.Debug.WriteLine("------in GetFormattedValue-------" + value.ToString());
        }

        DateTime valueAsFormatted;

        if (value != null && DateTime.TryParse(value.ToString(), out valueAsFormatted))
        {
            //succeeded
        }
        else
        {
            valueAsFormatted = new DateTime(2222, 2, 22);
            //failed
        }

        return(base.GetFormattedValue(valueAsFormatted.ToShortDateString(), rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
    }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value == null || value == DBNull.Value || rowIndex == this.DataGridView.NewRowIndex)
     {
         return(null);
     }
     return(Properties.Resources.BinaryImage);
 }
Exemple #28
0
 //// Implements the
 //// IDataGridViewEditingControl.GetEditingControlFormattedValue method.
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     this.m_ValueChanged = true;
     this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
     return(EditingControlFormattedValue.ToString());
 }
Exemple #29
0
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value is Enum)
     {
         return(Culture.Get(value.ToString()));
     }
     else if (value != null)
     {
         return(value.ToString());
     }
     else
     {
         return("");
     }
 }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     // This method is required to make the ProgressCell consistent with the default ImageCell.
     return(proEmptyImage);
 }
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(VoteResult.ToString());
 }
Exemple #32
0
            protected override object GetFormattedValue(object value, int rowIndex,
                                                        ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
                                                        TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
            {
                MapGen gen = MapGen.Find((string)value);

                return(gen != null ? gen.Theme : null);
            }
Exemple #33
0
        private void b_delete_Click(object sender, EventArgs e)
        {
            common_file.common_app.get_czsj();
            if (xygz == common_file.common_xydw.krly_xydw)
            {
                if (common_file.common_roles.get_user_qx("B_xydwgl_sc", common_file.common_app.user_type) == false)
                {
                    return;
                }
            }
            if (xygz == common_file.common_xydw.xyrx_gzdw)
            {
                if (common_file.common_roles.get_user_qx("B_gzdwgl_sc", common_file.common_app.user_type) == false)
                {
                    return;
                }
            }
            if (DS_Yxydw != null && DS_Yxydw.Tables[0].Rows.Count > 0)
            {
                if (common_file.common_app.message_box_show_select(common_file.common_app.message_title, "是否要删除所选中的记录!") == true)
                {
                    int j = 0; string s = "";
                    for (int i = 0; i < dg_count; i++)
                    {
                        common_file.common_app.get_czsj();
                        DataGridViewDataErrorContexts ss = new DataGridViewDataErrorContexts();
                        if (this.dg_xydw.Rows[i].Cells[0].GetEditedFormattedValue(i, ss) != null && Convert.ToBoolean(this.dg_xydw.Rows[i].Cells[0].GetEditedFormattedValue(i, ss)) == true)
                        {
                            //j = Convert.ToInt32(dg_xydw.Rows[i].Index.ToString());

                            DataRowView dgr = dg_xydw.Rows[i].DataBoundItem as DataRowView;
                            j = DS_Yxydw.Tables[0].Rows.IndexOf(dgr.Row);


                            if (DS_Yxydw.Tables[0].Rows[j]["id"].ToString() != "")
                            {
                                byte[]   imageb = new byte[0];
                                string   url    = common_file.common_app.service_url + "Yyxzx/Yyxzx_app.asmx";
                                object[] args   = new object[21];
                                args[0]  = DS_Yxydw.Tables[0].Rows[j]["id"].ToString();
                                args[1]  = common_file.common_app.yydh;
                                args[2]  = common_file.common_app.qymc;
                                args[3]  = "";
                                args[4]  = "";
                                args[5]  = "";
                                args[6]  = "";
                                args[7]  = "";
                                args[8]  = "";
                                args[9]  = "";
                                args[10] = "";
                                args[11] = "";
                                args[12] = "";
                                args[13] = "";
                                args[14] = "";

                                args[15] = imageb;
                                args[16] = "";
                                args[17] = "";
                                args[18] = common_file.common_app.get_delete;
                                args[19] = common_file.common_app.xxzs;
                                args[20] = "0";

                                Hotel_app.Server.Yyxzx.Yxydw Yxydw_services = new Hotel_app.Server.Yyxzx.Yxydw();
                                string result = Yxydw_services.Yxydw_add_edit(args[0].ToString(), args[1].ToString(), args[2].ToString(), args[3].ToString(), args[4].ToString(), args[5].ToString(), args[6].ToString(), args[7].ToString(), args[8].ToString(), args[9].ToString(), args[10].ToString(), args[11].ToString(), args[12].ToString(), args[13].ToString(), args[14].ToString(), imageb, args[16].ToString(), args[17].ToString(), args[18].ToString(), args[19].ToString(), args[20].ToString());
                                //object result = Hotel_app.我的替换DynamicWebServiceCall.InvokeWebService(url, "Yxydw_add_edit", args);
                                if (result == common_file.common_app.get_suc && (s == common_file.common_app.get_suc || s == ""))
                                {
                                    s = common_file.common_app.get_suc;
                                }
                                else
                                {
                                    s = common_file.common_app.get_failure;
                                }
                            }
                        }
                    }
                    if (s == common_file.common_app.get_suc)
                    {
                        common_file.common_app.Message_box_show(common_file.common_app.message_title, "删除成功!");
                    }
                    else
                    if (s == common_file.common_app.get_failure)
                    {
                        common_file.common_app.Message_box_show(common_file.common_app.message_title, "删除不成功!");
                    }
                    refresh_app();
                }
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #34
0
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            object x = base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);

            return("...");
        }
Exemple #35
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the text value of the cell's TsString and uses it as the value to display.
        /// </summary>
        /// <param name="value">The value to be formatted.</param>
        /// <param name="rowIndex">The index of the cell's parent row.</param>
        /// <param name="cellStyle">The <see cref="T:System.Windows.Forms.DataGridViewCellStyle"/>
        /// in effect for the cell.</param>
        /// <param name="valueTypeConverter">A <see cref="T:System.ComponentModel.TypeConverter"/>
        /// associated with the value type that provides custom conversion to the formatted value
        /// type, or null if no such custom conversion is needed.</param>
        /// <param name="formattedValueTypeConverter">A <see cref="T:System.ComponentModel.TypeConverter"/>
        /// associated with the formatted value type that provides custom conversion from the value
        /// type, or null if no such custom conversion is needed.</param>
        /// <param name="context">A bitwise combination of
        /// <see cref="T:System.Windows.Forms.DataGridViewDataErrorContexts"/> values describing
        /// the context in which the formatted value is needed.</param>
        /// <returns>
        /// The formatted value of the cell or null if the cell does not belong to a
        /// <see cref="T:System.Windows.Forms.DataGridView"></see> control.
        /// </returns>
        /// <exception cref="T:System.Exception">Formatting failed and either there is no
        /// handler for the <see cref="E:System.Windows.Forms.DataGridView.DataError"/> event
        /// of the <see cref="T:System.Windows.Forms.DataGridView"></see> control or the
        /// handler set the <see cref="P:System.Windows.Forms.DataGridViewDataErrorEventArgs.ThrowException"/>
        /// property to true. The exception object can typically be cast to type
        /// <see cref="T:System.FormatException"></see>.</exception>
        /// ------------------------------------------------------------------------------------
        protected override object GetFormattedValue(object value, int rowIndex,
                                                    ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
                                                    TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            ITsString tssValue = value as ITsString;

            return(base.GetFormattedValue(tssValue != null ? tssValue.Text : string.Empty,
                                          rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
        }
 public object GetEditedFormattedValue(int rowIndex, DataGridViewDataErrorContexts context)
 {
 }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            if (DataGridView == null || value == null)
            {
                if (threeState)
                {
                    return(CheckState.Indeterminate);
                }
                else
                {
                    return(false);
                }
            }

            return(value);
        }
Exemple #38
0
 // Constructors
 public DataGridViewDataErrorEventArgs(System.Exception exception, int columnIndex, int rowIndex, DataGridViewDataErrorContexts context)
 {
 }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     return((value as AsyncLabelViewModel)?.Text);
 }
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle,
     TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     return value.ToString();
 }
Exemple #41
0
		public object GetEditedFormattedValue (int rowIndex, DataGridViewDataErrorContexts context)
		{
			if (DataGridView == null)
				return null;
			
			if (rowIndex < 0 || rowIndex >= DataGridView.RowCount)
				throw new ArgumentOutOfRangeException ("rowIndex", "Specified argument was out of the range of valid values.");
			
			// If we are in edit mode, this returns the value of the editing control
			// If we aren't in edit mode, return the cell's value
			// Basically, return what the user is currently seeing
			if (IsInEditMode) {
				if (DataGridView.EditingControl != null)
					return (DataGridView.EditingControl as IDataGridViewEditingControl).GetEditingControlFormattedValue (context);
				else
					return (this as IDataGridViewEditingCell).GetEditingCellFormattedValue (context);
			}
				
			DataGridViewCellStyle style = InheritedStyle;
			
			return GetFormattedValue (GetValue (rowIndex), rowIndex, ref style, null, null, context);
		}
 /// <summary>
 /// Retrieves the formatted value of the cell.
 /// </summary>
 /// <param name="context">A bitwise combination of <see cref="DataGridViewDataErrorContexts"/> values that specifies the context in which the data is needed.</param>
 /// <returns>An <see cref="object"/> that represents the formatted version of the cell contents.</returns>
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(EditingControlFormattedValue);
 }
	public object GetEditedFormattedValue(int rowIndex, DataGridViewDataErrorContexts context) {}
Exemple #44
0
            protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle,
                                                        TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
            {
                var target = value as Target;

                if (target == null)
                {
                    return(base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
                }
                return(TargetResolver.FormatTarget(target));
            }
        ///<summary>
        ///Retrieves the formatted value of the cell.
        ///</summary>
        ///
        ///<returns>
        ///An <see cref="T:System.Object"></see> that represents the formatted version of the cell contents.
        ///</returns>
        ///
        ///<param name="context">A bitwise combination of <see cref="T:System.Windows.Forms.DataGridViewDataErrorContexts"></see> values that specifies the context in which the data is needed.</param>
        public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
        {
            if (mv.MonthViewControl.IsNull)
            {
                return string.Empty;
            }

            return SelectedDateTime.Value.ToString("G");
        }
Exemple #46
0
 // Implements the
 // IDataGridViewEditingControl.GetEditingControlFormattedValue method.
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(this.Value.Name);
     //return Color.Name;
 }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            DataGridViewColumnAdvanced ncol = (DataGridViewColumnAdvanced)GetColumn();

            if (ncol.DataType == ColumnDataType.Password)
            {
                if (value == null)
                {
                    return("");
                }
                else
                if (value == DBNull.Value)
                {
                    return("");
                }
                else
                if (value.ToString().Length == 0)
                {
                    return("");
                }
                else
                {
                    return("" + (char)0x25CF + (char)0x25CF + (char)0x25CF + (char)0x25CF + (char)0x25CF + (char)0x25CF);
                }
            }
            else
            {
                return(base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
            }
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     return(m_Control);
 }
 /// <summary>
 /// Retrieves the formatted value of the cell.
 /// </summary>
 /// <returns>
 /// An <see cref="T:System.Object"/> that represents the formatted version of the cell contents.
 /// </returns>
 /// <param name="context">A bitwise combination of <see cref="T:System.Windows.Forms.DataGridViewDataErrorContexts"/> values that specifies the context in which the data is needed.</param>
 object IDataGridViewEditingControl.GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(GetFormattedValue());
 }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            TransDirection dir = (TransDirection)value;

            if (dir == TransDirection.Buy)
            {
                return("买");
            }
            else
            {
                return("卖");
            }
        }
Exemple #51
0
 // Implements the IDataGridViewEditingControl.GetEditingControlFormattedValue method.
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     //return (EditingControlFormattedValue as IEnumerable<CheckedComboBoxItem>).Aggregate(new StringBuilder(), (s, i) => s.AppendFormat("{0}, ", i.Text), s => s.Length > 0 ? s.ToString(0, s.Length - 2) : String.Empty);
     return(this.EditingControlFormattedValue);
 }
Exemple #52
0
		protected virtual object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
		{
			if (DataGridView == null)
				return null;
				
			if (rowIndex < 0 || rowIndex >= DataGridView.RowCount)
				throw new ArgumentOutOfRangeException ("rowIndex");

			// Give the user a chance to custom format
			if (!(this is DataGridViewRowHeaderCell)) {
				DataGridViewCellFormattingEventArgs e = new DataGridViewCellFormattingEventArgs (ColumnIndex, rowIndex, value, FormattedValueType, cellStyle);
				DataGridView.OnCellFormattingInternal (e);
			
				if (e.FormattingApplied)
					return e.Value;
			
				cellStyle = e.CellStyle;
				value = e.Value;
			}
			
			if (value == null || (cellStyle != null && value == cellStyle.DataSourceNullValue)) {
				if (FormattedValueType == typeof (string))
					return String.Empty;
			}

			if (FormattedValueType == typeof(string) && value is IFormattable && !String.IsNullOrEmpty (cellStyle.Format))
				return ((IFormattable) value).ToString (cellStyle.Format, cellStyle.FormatProvider);
			if (value != null && FormattedValueType.IsAssignableFrom (value.GetType()))
				return value;

			if (formattedValueTypeConverter == null)
				formattedValueTypeConverter = FormattedValueTypeConverter;
			if (valueTypeConverter == null)
				valueTypeConverter = ValueTypeConverter;

			if (valueTypeConverter != null && valueTypeConverter.CanConvertTo (FormattedValueType))
				return valueTypeConverter.ConvertTo (value, FormattedValueType);
			if (formattedValueTypeConverter != null && formattedValueTypeConverter.CanConvertFrom (ValueType))
				return formattedValueTypeConverter.ConvertFrom (value);

			return Convert.ChangeType (value, FormattedValueType);
		}
 public DataGridViewDataErrorEventArgs(Exception exception, int columnIndex, int rowIndex, DataGridViewDataErrorContexts context) : base(columnIndex, rowIndex)
 {
     Exception = exception;
     Context   = context;
 }
 /// <summary>
 /// Returns the current value of the editing control.
 /// </summary>
 public virtual object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     bool userEdit = this.UserEdit;
     try
     {
         // Prevent the Value from being set to Maximum or Minimum when the cell is being painted.
         this.UserEdit = (context & DataGridViewDataErrorContexts.Display) == 0;
         return this.Value.ToString((this.ThousandsSeparator ? "N" : "F") + this.DecimalPlaces.ToString());
     }
     finally
     {
         this.UserEdit = userEdit;
     }
 }
Exemple #55
0
            protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle,
                                                        TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
            {
                var listItem = value as ListItem;

                if (listItem != null && listItem.GetRecord() is ListItem.OrphanRecordData)
                {
                    return(listItem.ToString(Style.Format, Style.FormatProvider));
                }
                object result = base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter,
                                                       formattedValueTypeConverter, context);

                return(result);
            }
Exemple #56
0
        /// <summary>編集コントロールで変更されたセルの値</summary>
        public object GetEditingControlFormattedValue(
            DataGridViewDataErrorContexts context)
        {
            ////return this.Text;// 編集処理がある場合工夫が必要
            //System.Diagnostics.Debug.WriteLine("GetEditingControlFormattedValue");
            //System.Diagnostics.Debug.WriteLine("・DataGridViewDataErrorContexts:" + context.ToString());
            //System.Diagnostics.Debug.WriteLine("・this.Text:" + this.Text);

            if (context ==
                (DataGridViewDataErrorContexts.Formatting
                 | DataGridViewDataErrorContexts.Display))
            {
                // 編集モードに入るとき
            }
            else if (context ==
                     (DataGridViewDataErrorContexts.Parsing
                      | DataGridViewDataErrorContexts.Commit))
            {
                // マウスで抜けた場合

                // 例外あり。
                if (this.Edited)
                {
                    // 下端でEnterで抜けた場合
                    this.PreValidate();
                    this.ReEdit();
                }
            }
            else if (context ==
                     (DataGridViewDataErrorContexts.Parsing
                      | DataGridViewDataErrorContexts.Commit
                      | DataGridViewDataErrorContexts.CurrentCellChange))
            {
                // Tab、Enterで抜けた場合
                this.PreValidate();
                this.ReEdit();
            }
            else if (context ==
                     (DataGridViewDataErrorContexts.Parsing
                      | DataGridViewDataErrorContexts.Commit
                      | DataGridViewDataErrorContexts.LeaveControl))
            {
                // 上端でShift + Tabで抜けた場合
                this.PreValidate();
                this.ReEdit();
            }
            else
            {
                // 不明
            }

            return(this.Text);

            //// バインド先を変更
            //if (this.DisplayUnits == null)
            //{
            //    // 単位変換無し。
            //    return this.Text;
            //}
            //else
            //{
            //    // 単位変換有り。
            //    return this.Value;
            //}
        }
Exemple #57
0
 ////   Get the value of the editing control for formatting.
 public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
 {
     return(this.NumericText);
     //return this.Text;
 }
 // Implements the
 // IDataGridViewEditingControl.GetEditingControlFormattedValue method.
 public object GetEditingControlFormattedValue(
     DataGridViewDataErrorContexts context)
 {
     return EditingControlFormattedValue;
 }
		public virtual object GetEditingControlFormattedValue (DataGridViewDataErrorContexts context) {
			return Text;
		}
 /// <summary>
 /// Customized implementation of the GetFormattedValue function 
 /// in order to include the buttons font in the formatted
 /// representation of the cell value.
 /// </summary>
 /// <param name="value">The value to be formatted. </param>
 /// <param name="rowIndex">The index of the cell's parent row.</param>
 /// <param name="cellStyle">The <see cref="DataGridViewCellStyle"/> in effect for the cell.</param>
 /// <param name="valueTypeConverter">A <see cref="TypeConverter"/> associated with the value 
 /// type that provides custom conversion to the formatted value type, 
 /// or a null reference (Nothing in Visual Basic) if no such custom conversion is needed.</param>
 /// <param name="formattedValueTypeConverter">A <see cref="TypeConverter"/> associated with the 
 /// formatted value type that provides custom conversion from the value type,
 /// or a null reference (Nothing in Visual Basic) if no such custom conversion is needed.</param>
 /// <param name="context">A bitwise combination of <see cref="DataGridViewDataErrorContexts"/> values 
 /// describing the context in which the formatted value is needed.</param>
 /// <returns>The formatted value of the cell or a null reference (Nothing in Visual Basic) if the cell does not belong to a <see cref="DataGridView"/> control.</returns>
 protected override object GetFormattedValue(object value,
                                             int rowIndex,
                                             ref DataGridViewCellStyle cellStyle,
                                             TypeConverter valueTypeConverter,
                                             TypeConverter formattedValueTypeConverter,
                                             DataGridViewDataErrorContexts context)
 {
   // By default, the base implementation converts the Decimal 1234.5 into the string "1234.5"
   object formattedValue = base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
   string formattedString = formattedValue as string;
   if (!string.IsNullOrEmpty(formattedString) && value != null)
   {
     TypeConverter FontConverter = TypeDescriptor.GetConverter(typeof(Font));
     this.NewFont = (Font)FontConverter.ConvertFromInvariantString(formattedString);
     //this.NewFont = ObjectStringConverter.StringToFont(formattedString);
   }
   return formattedValue;
 }