当前位置: 首页>>代码示例>>C#>>正文


C# Controls.DataGrid类代码示例

本文整理汇总了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);
 }
开发者ID:ibratoev,项目名称:MEF.NET35,代码行数:7,代码来源:StyleExtension.cs

示例2: FinAnalysisVM

 public FinAnalysisVM(DataGrid dataGrid)
 {
     _dataGrid = dataGrid;
     _rowMapping = Rowmapping.EnglishRows();
     _showTable = new ObservableCollection<FinAnalysisData>();
     _columnHeader = new List<string>();
 }
开发者ID:AFFA,项目名称:Project,代码行数:7,代码来源:FinAnalysisVM.cs

示例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);
            }
        }
开发者ID:campersau,项目名称:NuGetPackageExplorer,代码行数:26,代码来源:PackageRowDetails.xaml.cs

示例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;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:26,代码来源:PrintExtensions.cs

示例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;
 }
开发者ID:dggowda047,项目名称:itraacv2-1,代码行数:7,代码来源:iTRAACHelpers.cs

示例6: Paste

 private void Paste(DataGrid dataGrid)
 {
     Contract.Requires(dataGrid != null);
     var data = ClipboardHelper.GetClipboardDataAsTable();
     if (data != null)
         dataGrid.PasteCells(data);
 }
开发者ID:trzombie,项目名称:ProjectConfigurationManager,代码行数:7,代码来源:PropertiesViewModel.cs

示例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;
            }
        }
开发者ID:yurijdvornyk,项目名称:mathproblemsolver,代码行数:31,代码来源:ResultsControl.xaml.cs

示例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;
 }
开发者ID:Hakerok,项目名称:BD_Computer_Company,代码行数:31,代码来源:Window5.g.i.cs

示例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;
			}
		}
开发者ID:kknet,项目名称:StockSharp,代码行数:7,代码来源:Level2Panel.xaml.cs

示例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);
 }
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:7,代码来源:GenericDataGridTemplateColumn.cs

示例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);

        }
开发者ID:ibratoev,项目名称:MEF.NET35,代码行数:29,代码来源:AutoCompleteExtension.cs

示例12: ExcelHelper

 public ExcelHelper(String path , DataGrid dataGrid, DateTime startDate, DateTime endDate)
 {
     this.startDate = startDate;
     this.endDate = endDate;
     this.dataGrid = dataGrid;
     this.path = path;
 }
开发者ID:efraingtz,项目名称:leposwpf,代码行数:7,代码来源:ExcelHelper.cs

示例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;
 }
开发者ID:AhmedRagheb,项目名称:WPF-MVVM-SimpleProject,代码行数:7,代码来源:DataGridChangeBehavior.cs

示例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);
				}
			}
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:31,代码来源:GKUsersView.xaml.cs

示例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;
 }
开发者ID:Zhambul,项目名称:TimeTable,代码行数:25,代码来源:EditDayWindow.g.cs


注:本文中的System.Windows.Controls.DataGrid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。