本文整理汇总了C#中DataGridCell类的典型用法代码示例。如果您正苦于以下问题:C# DataGridCell类的具体用法?C# DataGridCell怎么用?C# DataGridCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridCell类属于命名空间,在下文中一共展示了DataGridCell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:rajeshwarn,项目名称:URLSchemeViewer,代码行数:8,代码来源:MainForm.cs
示例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));
}
开发者ID:MartyIX,项目名称:SoTh,代码行数:9,代码来源:PendingGamesControl.xaml.cs
示例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);
}
开发者ID:vansickle,项目名称:dbexplorer,代码行数:10,代码来源:DataGridDateTimeColumn.xaml.cs
示例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);
}
开发者ID:vansickle,项目名称:dbexplorer,代码行数:10,代码来源:DataGridDateTimeColumn.xaml.cs
示例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();
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:16,代码来源:DataGridCellAutomationPeer.cs
示例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;
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:14,代码来源:DataGridTextColumn.cs
示例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;
}
开发者ID:RookieOne,项目名称:ChangesAndValidation,代码行数:13,代码来源:GmtColumn.cs
示例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;
}
开发者ID:alexsharoff,项目名称:avstools,代码行数:14,代码来源:DataGridNumericColumn.cs
示例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;
}
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:77,代码来源:FeatureDataGrid.cs
示例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);
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:101,代码来源:FeatureDataGrid.cs
示例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;
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:15,代码来源:DataGrid.cs
示例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;
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:22,代码来源:DataGridHyperlinkColumn.cs
示例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;
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:14,代码来源:DataGridTextColumn.cs
示例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;
}
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:DataGridComboBoxColumn.cs
示例15: GenerateEditingElement
/// <summary>
/// Creates the visual tree that will become the content of a cell.
/// </summary>
protected abstract FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem);
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:DataGridColumn.cs
示例16: HandleSelectionForCellInput
/// <summary>
/// There was general input that means that selection should occur on
/// the given cell.
/// </summary>
/// <param name="cell">The target cell.</param>
/// <param name="startDragging">Whether the input also indicated that dragging should start.</param>
internal void HandleSelectionForCellInput(DataGridCell cell, bool startDragging, bool allowsExtendSelect, bool allowsMinimalSelect)
{
DataGridSelectionUnit selectionUnit = SelectionUnit;
// If the mode is None, then no selection will occur
if (selectionUnit == DataGridSelectionUnit.FullRow)
{
// In FullRow mode, items are selected
MakeFullRowSelection(cell.RowDataItem, allowsExtendSelect, allowsMinimalSelect);
}
else
{
// In the other modes, cells can be individually selected
MakeCellSelection(new DataGridCellInfo(cell), allowsExtendSelect, allowsMinimalSelect);
}
if (startDragging)
{
BeginDragging();
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:27,代码来源:DataGrid.cs
示例17: SelectAndEditOnFocusMove
private void SelectAndEditOnFocusMove(KeyEventArgs e, DataGridCell oldCell, bool wasEditing, bool allowsExtendSelect, bool ignoreControlKey)
{
DataGridCell newCell = GetCellForSelectAndEditOnFocusMove();
if ((newCell != null) && (newCell.DataGridOwner == this))
{
if (ignoreControlKey || ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == 0))
{
if (ShouldSelectRowHeader && allowsExtendSelect)
{
HandleSelectionForRowHeaderAndDetailsInput(newCell.RowOwner, /* startDragging = */ false);
}
else
{
HandleSelectionForCellInput(newCell, /* startDragging = */ false, allowsExtendSelect, /* allowsMinimalSelect = */ false);
}
}
// If focus moved to a new cell within the same row that didn't
// decide on its own to enter edit mode, put it in edit mode.
if (wasEditing && !newCell.IsEditing && (oldCell.RowDataItem == newCell.RowDataItem))
{
BeginEdit(e);
}
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:26,代码来源:DataGrid.cs
示例18: CellIsSelectedChanged
/// <summary>
/// Notification that a particular cell's IsSelected property changed.
/// </summary>
internal void CellIsSelectedChanged(DataGridCell cell, bool isSelected)
{
if (!IsUpdatingSelectedCells)
{
DataGridCellInfo cellInfo = new DataGridCellInfo(cell);
if (isSelected)
{
_selectedCells.AddValidatedCell(cellInfo);
}
else if (_selectedCells.Contains(cellInfo))
{
_selectedCells.Remove(cellInfo);
}
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:18,代码来源:DataGrid.cs
示例19: UpdateRowEditing
private void UpdateRowEditing(DataGridCell cell)
{
object rowDataItem = cell.RowDataItem;
// If the row is not in edit/add mode, then clear its IsEditing flag.
if (!IsAddingOrEditingRowItem(rowDataItem))
{
cell.RowOwner.IsEditing = false;
_editingRowItem = null;
_editingRowIndex = -1;
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:12,代码来源:DataGrid.cs
示例20: EndEdit
private bool EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, bool exitEditMode)
{
bool cellLeftEditingMode = true;
bool rowLeftEditingMode = true;
if (cellContainer != null)
{
if (command.CanExecute(editingUnit, cellContainer))
{
command.Execute(editingUnit, cellContainer);
}
cellLeftEditingMode = !cellContainer.IsEditing;
rowLeftEditingMode = !IsEditingRowItem && !IsAddingNewItem;
}
if (!exitEditMode)
{
if (editingUnit == DataGridEditingUnit.Cell)
{
if (cellContainer != null)
{
if (cellLeftEditingMode)
{
return BeginEdit(null);
}
}
else
{
// A cell was not placed in edit mode
return false;
}
}
else
{
if (rowLeftEditingMode)
{
object rowItem = cellContainer.RowDataItem;
if (rowItem != null)
{
EditRowItem(rowItem);
return IsEditingRowItem;
}
}
// A row item was not placed in edit mode
return false;
}
}
return cellLeftEditingMode && ((editingUnit == DataGridEditingUnit.Cell) || rowLeftEditingMode);
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:52,代码来源:DataGrid.cs
注:本文中的DataGridCell类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论