本文整理汇总了C#中DataGridCell类的典型用法代码示例。如果您正苦于以下问题:C# DataGridCell类的具体用法?C# DataGridCell怎么用?C# DataGridCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataGridCell类属于命名空间,在下文中一共展示了DataGridCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addRow
private void addRow(DataGridCell cell)
{
int ID = dataGridView.Rows.Count + 1;
string[] row = new string[] {ID.ToString(), cell.bundleID, cell.executeName, cell.scheme};
dataGridView.Rows.Add(row);
dataGridView.Rows[0].ReadOnly = false;
}
示例2: GetRowIndex
public static int GetRowIndex(DataGridCell dataGridCell)
{
// Use reflection to get DataGridCell.RowDataItem property value.
PropertyInfo rowDataItemProperty = dataGridCell.GetType().GetProperty("RowDataItem", BindingFlags.Instance | BindingFlags.NonPublic);
DataGrid dataGrid = GetDataGridFromChild(dataGridCell);
return dataGrid.Items.IndexOf(rowDataItemProperty.GetValue(dataGridCell, null));
}
示例3: GenerateEditingElement
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
var binding = new Binding(bindingPath) {Mode = BindingMode.TwoWay, Converter = new DateTimeConverter()};
var textBlock = new TextBox();
textBlock.SetBinding(TextBox.TextProperty, binding);
textBlock.Margin = new Thickness(0, 0, 2, 0);
return BuildElement(textBlock);
}
示例4: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
var binding = new Binding(bindingPath);
var textBlock = new TextBlock();
textBlock.SetBinding(TextBlock.TextProperty, binding);
textBlock.Margin = new Thickness(0, 0, 2, 0);
return BuildElement(textBlock);
}
示例5: DataGridCellAutomationPeer
/// <summary>
/// AutomationPeer for DataGridCell.
/// This automation peer should not be part of the automation tree.
/// It should act as a wrapper peer for DataGridCellItemAutomationPeer
/// </summary>
/// <param name="owner">DataGridCell</param>
public DataGridCellAutomationPeer(DataGridCell owner)
: base(owner)
{
if (owner == null)
{
throw new ArgumentNullException("owner");
}
UpdateEventSource();
}
示例6: GenerateElement
/// <summary>
/// Creates the visual tree for text based cells.
/// </summary>
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
TextBlock textBlock = new TextBlock();
SyncProperties(textBlock);
ApplyStyle(/* isEditing = */ false, /* defaultToElementStyle = */ false, textBlock);
ApplyBinding(textBlock, TextBlock.TextProperty);
return textBlock;
}
示例7: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
var control = new ContentControl();
var binding = CreateBinding();
BindingOperations.SetBinding(control, ContentPresenter.ContentProperty, binding);
var template = GetDisplayTemplate(dataItem);
control.ContentTemplate = template;
return control;
}
示例8: GenerateEditingElement
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
var numericEditor = new DoubleUpDown();
numericEditor.Minimum = Minimum;
numericEditor.Maximum = Maximum;
numericEditor.Increment = Increment;
numericEditor.FormatString = FormatString;
var sourceBinding = this.Binding as System.Windows.Data.Binding;
var binding = new System.Windows.Data.Binding();
binding.Path = sourceBinding.Path;
binding.Converter = new TargetTypeConverter();
numericEditor.SetBinding(DoubleUpDown.ValueProperty, binding);
return numericEditor;
}
示例9: GenerateElement
/// <summary>
/// When overridden in a derived class, gets a read-only element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding"/> property value.
/// </summary>
/// <param name="cell">The cell that will contain the generated element.</param>
/// <param name="dataItem">The data item represented by the row that contains the intended cell.</param>
/// <returns>
/// A new, read-only element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding"/> property value.
/// </returns>
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
TextBlock block = new TextBlock
{
Margin = new Thickness(4.0),
VerticalAlignment = VerticalAlignment.Center
};
if (!string.IsNullOrEmpty(Field))
{
var codedValueSources = Utilities.DynamicCodedValueSource.GetCodedValueSources(LookupField, FieldInfo, dataItem, DynamicCodedValueSource, nullableSources);
if (codedValueSources != null)
{
if (!string.IsNullOrEmpty(LookupField) && DynamicCodedValueSource != null)
{
nameConverter.LookupField = this.LookupField;
nameConverter.Field = this.Field;
Binding binding =
#if SILVERLIGHT
new Binding();
#else
new Binding("Attributes["+Field+"]");
#endif
binding.Mode = BindingMode.OneWay;
binding.Converter = nameConverter;
binding.ConverterParameter =
#if SILVERLIGHT
DynamicCodedValueSource;
#else
new Object[] { DynamicCodedValueSource, block };
#endif
block.SetBinding(TextBlock.TextProperty, binding);
}
}
else if (FieldInfo.Type == Client.Field.FieldType.Date)
{
if (!string.IsNullOrEmpty(Field))
{
dateTimeConverter.DateTimeFormat = this.DateTimeFormat;
dateTimeConverter.DateTimeKind = this.DateTimeKind;
Binding binding =
#if SILVERLIGHT
new Binding(Field);
#else
new Binding("Attributes["+Field+"]");
#endif
binding.Mode = BindingMode.OneWay;
binding.Converter = dateTimeConverter;
block.SetBinding(TextBlock.TextProperty, binding);
}
}
else
{
Binding binding =
#if SILVERLIGHT
new Binding(Field);
#else
new Binding("Attributes["+Field+"]");
#endif
binding.Mode = BindingMode.OneWay;
block.SetBinding(TextBlock.TextProperty, binding);
}
}
return block;
}
示例10: GenerateEditingElement
/// <summary>
/// When overridden in a derived class, gets an editing element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding"/> property value.
/// </summary>
/// <param name="cell">The cell that will contain the generated element.</param>
/// <param name="dataItem">The data item represented by the row that contains the intended cell.</param>
/// <returns>
/// A new editing element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding"/> property value.
/// </returns>
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
#if !SILVERLIGHT
_isEditing = false;
#endif
if(!string.IsNullOrEmpty(Field))
{
var codedValueSources = Utilities.DynamicCodedValueSource.GetCodedValueSources(LookupField, FieldInfo, dataItem, DynamicCodedValueSource, nullableSources);
if (codedValueSources != null)
{
ComboBox box = new ComboBox
{
Margin = new Thickness(4.0),
VerticalAlignment = VerticalAlignment.Center,
VerticalContentAlignment = VerticalAlignment.Center,
DisplayMemberPath = "DisplayName"
};
if (!string.IsNullOrEmpty(LookupField) && DynamicCodedValueSource != null)
{
// Item Source Binding
lookupConverter.LookupField = this.LookupField;
lookupConverter.Field = this.FieldInfo;
lookupConverter.NullableSources = this.nullableSources;
Binding binding = new Binding();
binding.Mode = BindingMode.OneWay;
binding.Converter = lookupConverter;
binding.ConverterParameter = DynamicCodedValueSource;
box.SetBinding(ComboBox.ItemsSourceProperty, binding);
// Selected Item Binding
selectedConverter.Field = Field;
selectedConverter.LookupField = LookupField;
selectedConverter.NullableSources = this.nullableSources;
Binding selectedBinding = new Binding();
selectedBinding.Mode = BindingMode.OneWay;
selectedBinding.Converter = selectedConverter;
selectedBinding.ConverterParameter = this.DynamicCodedValueSource;
box.SetBinding(ComboBox.SelectedItemProperty, selectedBinding);
box.SelectionChanged += box_SelectionChanged;
}
return box;
}
else if(FieldInfo.Type == Client.Field.FieldType.Date)
{
DateTimePicker dtp = new DateTimePicker
{
Margin = new Thickness(4.0),
VerticalAlignment = VerticalAlignment.Center,
VerticalContentAlignment = VerticalAlignment.Center,
DateTimeFormat = this.DateTimeFormat,
DateTimeKind = this.DateTimeKind,
Language = cell.Language
};
Binding selectedBinding =
#if SILVERLIGHT
new Binding(Field);
#else
new Binding("Attributes["+Field+"]");
if (FieldDomainUtils.IsDynamicDomain(FieldInfo, LayerInfo))
{
selectedBinding.ValidationRules.Add(new DynamicRangeDomainValidationRule()
{
ValidationStep = ValidationStep.ConvertedProposedValue,
Field = FieldInfo,
LayerInfo = LayerInfo,
Graphic = dataItem as Graphic
});
}
#endif
selectedBinding.Mode = BindingMode.TwoWay;
selectedBinding.ValidatesOnExceptions = true;
selectedBinding.NotifyOnValidationError = true;
dtp.SetBinding(DateTimePicker.SelectedDateProperty, selectedBinding);
return dtp;
}
else
{
TextBox box = new TextBox
{
Margin = new Thickness(4.0),
VerticalAlignment = VerticalAlignment.Center,
VerticalContentAlignment = VerticalAlignment.Center,
};
box.MaxLength = Field.Length;
Binding binding =
#if SILVERLIGHT
new Binding(Field);
//.........这里部分代码省略.........
示例11: CancelEdit
/// <summary>
/// Raises the CancelEdit command.
/// If a cell is currently in edit mode, cancels the cell edit, but leaves any row edits alone.
/// </summary>
/// <returns>true if the cell exits edit mode, false otherwise.</returns>
internal bool CancelEdit(DataGridCell cell)
{
DataGridCell currentCell = CurrentCellContainer;
if (currentCell != null && currentCell == cell && currentCell.IsEditing)
{
return CancelEdit(DataGridEditingUnit.Cell);
}
return true;
}
示例12: GenerateElement
/// <summary>
/// Creates the visual tree for cells.
/// </summary>
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
TextBlock outerBlock = new TextBlock();
Hyperlink link = new Hyperlink();
InlineUIContainer inlineContainer = new InlineUIContainer();
ContentPresenter innerContentPresenter = new ContentPresenter();
outerBlock.Inlines.Add(link);
link.Inlines.Add(inlineContainer);
inlineContainer.Child = innerContentPresenter;
link.TargetName = TargetName;
ApplyStyle(/* isEditing = */ false, /* defaultToElementStyle = */ false, outerBlock);
ApplyBinding(link, Hyperlink.NavigateUriProperty);
ApplyContentBinding(innerContentPresenter, ContentPresenter.ContentProperty);
return outerBlock;
}
示例13: GenerateEditingElement
/// <summary>
/// Creates the visual tree for text based cells.
/// </summary>
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
TextBox textBox = new TextBox();
SyncProperties(textBox);
ApplyStyle(/* isEditing = */ true, /* defaultToElementStyle = */ false, textBox);
ApplyBinding(textBox, TextBox.TextProperty);
return textBox;
}
示例14: GenerateEditingElement
/// <summary>
/// Creates the visual tree for text based cells.
/// </summary>
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
ComboBox comboBox = new ComboBox();
ApplyStyle(/* isEditing = */ true, /* defaultToElementStyle = */ false, comboBox);
ApplyColumnProperties(comboBox);
return comboBox;
}
示例15: GenerateEditingElement
/// <summary>
/// Creates the visual tree that will become the content of a cell.
/// </summary>
protected abstract FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem);