• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.DataGrid类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Controls.DataGrid的典型用法代码示例。如果您正苦于以下问题:C# DataGrid类的具体用法?C# DataGrid怎么用?C# DataGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataGrid类属于System.Windows.Controls命名空间,在下文中一共展示了DataGrid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: CreateCellTemplate

        internal static System.Windows.DataTemplate CreateCellTemplate(EntityFieldInfo entityFieldInfo,DataGrid dataGrid)
        {
            DataTemplate dataTemplate = new DataTemplate();
            FrameworkElementFactory contentControl = new FrameworkElementFactory(typeof(ContentControl));
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
            Style contentControlStyle = new Style();
            contentControl.SetValue(ContentControl.StyleProperty, contentControlStyle);

            DataTemplate tpl = new DataTemplate();
            if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Color)
            {
                FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
                Binding binding = CreateBindingOneWay(entityFieldInfo.Path);
                binding.Converter = new StringToBrushConverter();
                grid.SetBinding(Grid.BackgroundProperty, binding);
                tpl.VisualTree = grid;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }
            else
            {
                FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBlock));
                if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Pr)
                { textBox.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right); }
                textBox.SetBinding(TextBlock.TextProperty, CreateBindingOneWay(entityFieldInfo.Path));
                tpl.VisualTree = textBox;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }

            return dataTemplate;
        }
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:32,代码来源:DataGridTemplateBuilder.cs


示例17: CanCopy

        private bool CanCopy(DataGrid dataGrid)
        {
            if (dataGrid == null)
                return false;

            return dataGrid.HasRectangularCellSelection();
        }
开发者ID:trzombie,项目名称:ProjectConfigurationManager,代码行数:7,代码来源:PropertiesViewModel.cs


示例18: switch

        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
                case 1:
                    this.dummyElement = (FrameworkElement) target;
                    return;

                case 2:
                    this.itemsDataGrid = (DataGrid) target;
                    this.itemsDataGrid.PreviewKeyDown += new KeyEventHandler(this.dataGrid_PreviewKeyDown);
                    return;

                case 3:
                    this.saveToPcButton = (Button) target;
                    return;

                case 4:
                    this.deleteButton = (Button) target;
                    return;

                case 5:
                    this.cancelButton = (Button) target;
                    return;
            }
            this._contentLoaded = true;
        }
开发者ID:netonjm,项目名称:WindowsPhone,代码行数:27,代码来源:PhonePodcastsPanel.cs


示例19: ReadConfigurations

        /// <summary>
        /// Opens a 
        /// </summary>
        public void ReadConfigurations(DataGrid dgDataGrid1)
        {
            dgDataGrid = dgDataGrid1;
            //get adress of config xml
            FileInfo XMLfileInfo = FileIO.OpenFile();

            //read xml file
            if (XMLfileInfo != null)
            {
                Stream stream = XMLfileInfo.OpenRead();
                //convert xml file to object
                config = Converter.XMLToClasses(stream);

                stream.Close();
                //get Querry
                GetDBEntries( );

                //create Grid

            }
            else
            {
                errorFlag = true;
                MessageBox.Show("You haven't selected anything");
            }
        }
开发者ID:alienboal,项目名称:auto_grid,代码行数:29,代码来源:Driver.cs


示例20: ModifierClient

        public ModifierClient(Particulier p, Ressources r, DataGrid d)
        {
            client = p;
            res = r;
            data = d;

            InitializeComponent();

            if(p is Professionnel)
                pro = true;
            else
                pro = false;

            nom.Text = p.Nom;
            prenom.Text = p.Prenom;
            email.Text = p.EMail;
            telephone.Text = p.NumeroDeTelephone;

            if (pro)
            {
                Professionnel prof = client as Professionnel;

                siret.IsEnabled = true;
                siret.Text = prof.Siret;

                denomination.IsEnabled = true;
                denomination.Text = prof.Denomnation;
            }

            numvoie.Text = client.Adresse.Numero;
            voie.Text = client.Adresse.Voie;
            cp.Text = client.Adresse.CodePostal;
            ville.Text = client.Adresse.Ville;
            dep.Text = client.Adresse.Departement;
        }
开发者ID:Olwaro,项目名称:LocLacanau,代码行数:35,代码来源:ModifierClient.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.DataGridAutoGeneratingColumnEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Controls.ControlTemplate类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap