本文整理汇总了C#中System.Windows.Controls.DataGrid类的典型用法代码示例。如果您正苦于以下问题:C# DataGrid类的具体用法?C# DataGrid怎么用?C# DataGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGrid类属于System.Windows.Controls命名空间,在下文中一共展示了DataGrid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(DataGrid grid)
{
_grid = grid;
ImplicitStyleManager.SetResourceDictionaryUri(_grid, new Uri("ExtensibleGrid.Extensions;component/Theme.xaml", UriKind.Relative));
ImplicitStyleManager.SetApplyMode(grid, ImplicitStylesApplyMode.Auto);
ImplicitStyleManager.Apply(_grid);
}
示例2: FinAnalysisVM
public FinAnalysisVM(DataGrid dataGrid)
{
_dataGrid = dataGrid;
_rowMapping = Rowmapping.EnglishRows();
_showTable = new ObservableCollection<FinAnalysisData>();
_columnHeader = new List<string>();
}
示例3: ApplyBindings
public void ApplyBindings(DataGrid parent)
{
var gridView = (GridView)PackageGrid.View;
Debug.Assert(parent.Columns.Count == gridView.Columns.Count);
for (int i = 0; i < gridView.Columns.Count; i++)
{
var binding = new Binding("ActualWidth")
{
Source = parent.Columns[i]
};
if (i == 0)
{
// for the Id column, which is the first column,
// it is slightly smaller than the parent column width
// due to the left margin.
binding.Converter = subtractConverter;
binding.ConverterParameter = 3;
}
BindingOperations.SetBinding(
gridView.Columns[i],
GridViewColumn.WidthProperty,
binding);
}
}
示例4: ToPrintFriendlyGrid
public static DataGrid ToPrintFriendlyGrid(this DataGrid source,PagedCollectionView pcv)
{
DataGrid dg = new DataGrid();
dg.ItemsSource = pcv;
dg.AutoGenerateColumns = false;
for (int i = 0; i < source.Columns.Count; i++)
{
DataGridTextColumn newColumn = new DataGridTextColumn();
DataGridTextColumn column = (DataGridTextColumn)source.Columns[i];
newColumn.Header = column.Header;
System.Windows.Data.Binding bind;
if (column.Binding != null)
{
bind = new System.Windows.Data.Binding();
bind.Path = column.Binding.Path;
//bind.Converter = column.Binding.Converter;
}
else
bind = new System.Windows.Data.Binding();
newColumn.Binding = bind;
dg.Columns.Add(newColumn);
}
return dg;
}
示例5: WpfDataGridStandardBehavior
static public void WpfDataGridStandardBehavior(DataGrid grid)
{
grid.ContextMenu = Application.Current.FindResource("WPFDataGrid_CopyMenu") as ContextMenu;
grid.MouseRightButtonUp += WPFHelpers.WPFDataGridMouseRightButtonUpSaveCell;
grid.AutoGeneratingColumn += GridAutoGeneratingColumn;
grid.LoadingRow += GridLoadingRow;
}
示例6: Paste
private void Paste(DataGrid dataGrid)
{
Contract.Requires(dataGrid != null);
var data = ClipboardHelper.GetClipboardDataAsTable();
if (data != null)
dataGrid.PasteCells(data);
}
示例7: updateTable
private void updateTable(ProblemResult result)
{
ResultTabs.Clear();
for (int i = 0; i < result.TableResult.Values.Count; ++i)
{
ResultDataTable resultDataTable = new ResultDataTable(result.TableResult.Values[i]);
DataGrid dataGrid = new DataGrid();
dataGrid.IsReadOnly = true;
dataGrid.CanUserSortColumns = false;
dataGrid.CanUserAddRows = false;
dataGrid.CanUserDeleteRows = false;
dataGrid.CanUserResizeRows = false;
dataGrid.CanUserResizeColumns = false;
dataGrid.SelectionUnit = DataGridSelectionUnit.Cell;
dataGrid.ItemsSource = resultDataTable.AsDataView;
TabItem tabItem = new TabItem();
tabItem.Header =
string.IsNullOrEmpty(result.TableResult.Values[i].Title)
? (i + 1).ToString() : result.TableResult.Values[i].Title;
tabItem.Content = dataGrid;
ResultTabs.Add(tabItem);
}
if (ResultTabs.Count > 0)
{
tcResultsTabs.SelectedIndex = 0;
tcResultsTabs.SelectedItem = ResultTabs.First();
ResultTabs.First().IsSelected = true;
}
}
示例8: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.spdg = ((System.Windows.Controls.DataGrid)(target));
#line 6 "..\..\Window5.xaml"
this.spdg.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.spdg_SelectionChanged);
#line default
#line hidden
return;
case 2:
#line 22 "..\..\Window5.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);
#line default
#line hidden
return;
case 3:
#line 23 "..\..\Window5.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_2);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}
示例9: SetVisibleColumns
private static void SetVisibleColumns(DataGrid grid, HashSet<string> columns)
{
foreach (var column in grid.Columns)
{
column.Visibility = columns.Contains(column.SortMemberPath) ? Visibility.Visible : Visibility.Collapsed;
}
}
示例10: GenericDataGridTemplateColumn
public GenericDataGridTemplateColumn(EntityFieldInfo fieldInfo,DataGrid dataGrid)
{
this.FieldInfo = fieldInfo;
this.Header = this.FieldInfo.DisplayName;
this.CellTemplate = DataGridTemplateBuilder.CreateCellTemplate(this.FieldInfo, dataGrid);
this.CellEditingTemplate = DataGridTemplateBuilder.CreateCellEditingTemplate(this.FieldInfo, dataGrid);
}
示例11: Initialize
public void Initialize(DataGrid grid)
{
_grid = grid;
ResourceDictionary dictionary = Parse(new Uri("ExtensibleGrid.Extensions;component/AutoCompleteExtension.xaml", UriKind.Relative));
//loading the resource dictionary
DataGridColumn item = null;
int index = 0;
foreach (DataGridColumn col in _grid.Columns)
{
// turn every column of type string to an autocomplete
if (col.Header.Equals("FirstName") || col.Header.Equals("First Name"))
{
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
templateColumn.Header = col.Header;
templateColumn.CellEditingTemplate = dictionary["myCellEditingTemplateFirstName"] as DataTemplate;
_grid.Columns.Insert(index, templateColumn);
item = col;
break;
}
index++;
}
_grid.Columns.Remove(item);
}
示例12: ExcelHelper
public ExcelHelper(String path , DataGrid dataGrid, DateTime startDate, DateTime endDate)
{
this.startDate = startDate;
this.endDate = endDate;
this.dataGrid = dataGrid;
this.path = path;
}
示例13: CreateElementStyle
private static Style CreateElementStyle(DataGrid dataGrid, string bindingPath)
{
var baseStyle = dataGrid.FindResource("TextBlockBaseStyle") as Style;
var style = new Style(typeof(TextBlock), baseStyle);
AddSetters(style, bindingPath);
return style;
}
示例14: DataGridScroll
void DataGridScroll(ScrollChangedEventArgs e, DataGrid dataGrid1, DataGrid dataGrid2)
{
if (e.HorizontalChange != 0.0f)
{
ScrollViewer sv;
Type t = dataGrid1.GetType();
try
{
sv = t.InvokeMember("InternalScrollHost", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty, null, dataGrid2, null) as ScrollViewer;
sv.ScrollToHorizontalOffset(e.HorizontalOffset);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
if (e.VerticalChange != 0.0f)
{
ScrollViewer sv = null;
Type t = dataGrid1.GetType();
try
{
sv = t.InvokeMember("InternalScrollHost", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty, null, dataGrid2, null) as ScrollViewer;
sv.ScrollToVerticalOffset(e.VerticalOffset);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
示例15: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.MyDataGrid = ((System.Windows.Controls.DataGrid)(target));
return;
case 2:
#line 116 "..\..\..\..\Uil\Window\EditDayWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddLessonButton_Click);
#line default
#line hidden
return;
case 3:
#line 117 "..\..\..\..\Uil\Window\EditDayWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.SaveButton_Click);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}