本文整理汇总了C#中DataGridViewDataErrorContexts类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewDataErrorContexts类的具体用法?C# DataGridViewDataErrorContexts怎么用?C# DataGridViewDataErrorContexts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewDataErrorContexts类属于命名空间,在下文中一共展示了DataGridViewDataErrorContexts类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetFormattedValue
// ========================================================================
// 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;
}
开发者ID:gbaychev,项目名称:NClass,代码行数:25,代码来源:DataGridViewImageComboBoxColumnCell.cs
示例2: GetFormattedValue
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;
}
开发者ID:AlgorithmsOfMathdestruction,项目名称:meridian59-dotnet,代码行数:25,代码来源:ByteColumn.cs
示例3: GetFormattedValue
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;
}
开发者ID:altmer,项目名称:study-projects,代码行数:7,代码来源:CustomerIDColumn.cs
示例4: GetFormattedValue
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;
}
开发者ID:akhuang,项目名称:NetExercise,代码行数:30,代码来源:DataGridViewDownloadProgressCell.cs
示例5: GetFormattedValue
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;
}
开发者ID:JulianoW,项目名称:ffrkx,代码行数:7,代码来源:SeriesDataGridViewCell.cs
示例6: GetFormattedValue
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;
}
开发者ID:samysilva,项目名称:WUManager,代码行数:58,代码来源:DataGridViewProgressCell.cs
示例7: GetFormattedValue
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 "";
}
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:9,代码来源:GridViewPopupCell.cs
示例8: GetFormattedValue
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);
}
开发者ID:atan888,项目名称:MMS,代码行数:9,代码来源:DataGridViewEnumColumn.cs
示例9: DataGridViewDataErrorEventArgs
/// <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;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:DataGridViewDataErrorEventArgs.cs
示例10: GetFormattedValue
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);
}
开发者ID:anthanhcong,项目名称:atc-demand-instruction-form,代码行数:11,代码来源:DataGridViewTimeCell.cs
示例11: GetEditingControlFormattedValue
///// <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;
}
开发者ID:krt,项目名称:OpenTouryo,代码行数:60,代码来源:WinCustomMaskedTextBoxDgvHost.cs
示例12: GetFormattedValue
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;
}
}
开发者ID:burstas,项目名称:rmps,代码行数:53,代码来源:DataGridViewProgressCell.cs
示例13: GetFormattedValue
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);
}
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:12,代码来源:DataGridViewListColumn.cs
示例14: GetFormattedValue
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;
}
开发者ID:AlgorithmsOfMathdestruction,项目名称:meridian59-dotnet,代码行数:13,代码来源:InOutColumn.cs
示例15: GetFormattedValue
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);
}
开发者ID:svn2github,项目名称:eztx,代码行数:16,代码来源:Form1.cs
示例16: GetFormattedValue
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);
}
开发者ID:chenkyle,项目名称:footballMatch,代码行数:17,代码来源:DataGridViewComboBoxCell.cs
示例17: GetFormattedValue
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;
}
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:17,代码来源:GridViewJointDOFCell.cs
示例18: GetFormattedValue
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;
}
开发者ID:biddyweb,项目名称:communicator,代码行数:43,代码来源:ContactsList.cs
示例19: GetFormattedValue
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);
}
}
开发者ID:shengqh,项目名称:RCPA.Core,代码行数:19,代码来源:AnnotationCell.cs
示例20: GetFormattedValue
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;
}
开发者ID:PeletonSoft,项目名称:Orders,代码行数:41,代码来源:DataGridViewDictionaryCell.cs
注:本文中的DataGridViewDataErrorContexts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论