本文整理汇总了C#中DataGrid类的典型用法代码示例。如果您正苦于以下问题:C# DataGrid类的具体用法?C# DataGrid怎么用?C# DataGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGrid类属于命名空间,在下文中一共展示了DataGrid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PositionToCellRange_OutOfBounds
public void PositionToCellRange_OutOfBounds()
{
DataGrid grid1 = new DataGrid();
List<int> list = new List<int>();
grid1.DataSource = new DevAge.ComponentModel.BoundList<int>(list);
Assert.AreEqual(Range.Empty, grid1.PositionToCellRange(new Position(5, 5)));
}
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:7,代码来源:TestDataGrid_PositionToCellRange.cs
示例2: ExportDataSetToExcel
public static void ExportDataSetToExcel(DataSet ds, string filename)
{
try
{
HttpResponse response = HttpContext.Current.Response;
// first let's clean up the response.object
response.Clear();
response.Charset = "";
// set the response mime type for excel
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
// create a string writer
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// instantiate a datagrid
DataGrid dg = new DataGrid();
dg.Font.Size = 9;
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
response.End();
}
}
}
catch (Exception)
{
throw;
}
}
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:35,代码来源:master_materials.aspx.cs
示例3: ExportDataGrid
public static void ExportDataGrid(DataGrid dGrid, String author, String companyName, String mergeCells, int boldHeaderRows, string fileName)
{
if (Application.Current.HasElevatedPermissions)
{
var filePath ="C:" + Path.DirectorySeparatorChar +"Nithesh"+Path.DirectorySeparatorChar +fileName + ".XML";
File.Create(filePath);
Stream outputStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite);
ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, "XML", outputStream);
}
else
{
SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xml", Filter = FILE_FILTER, FilterIndex = 2, DefaultFileName = fileName };
if (objSFD.ShowDialog() == true)
{
string strFormat = objSFD.SafeFileName.Substring(objSFD.SafeFileName.IndexOf('.') + 1).ToUpper();
Stream outputStream = objSFD.OpenFile();
ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, strFormat, outputStream);
}
}
}
开发者ID:shenoyroopesh,项目名称:Gama,代码行数:25,代码来源:DataGridExtensions.cs
示例4: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 24);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(264, 216);
this.dataGrid1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 317);
this.Controls.Add (this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
开发者ID:hitswa,项目名称:winforms,代码行数:33,代码来源:kb318581.cs
示例5: BindItemsSource
public void BindItemsSource()
{
// Create the original DataContext object
StringsContainer stringsContainer1 = new StringsContainer();
stringsContainer1.Strings = new ObservableCollection<string> { "first", "second", "third" };
// Create the next object to be used as DataContext
StringsContainer stringsContainer2 = new StringsContainer();
stringsContainer2.Strings = new ObservableCollection<string> { "one", "two", "three", "four", "five" };
// Create the DataGrid and setup its binding
DataGrid dataGrid = new DataGrid();
dataGrid.DataContext = stringsContainer1;
Binding binding = new Binding("Strings");
binding.Mode = BindingMode.OneWay;
dataGrid.SetBinding(DataGrid.ItemsSourceProperty, binding);
TestPanel.Children.Add(dataGrid);
this.EnqueueCallback(delegate
{
Assert.AreEqual(stringsContainer1.Strings, dataGrid.ItemsSource, "ItemsSource was not set from the original DataContext");
Assert.AreEqual(3, dataGrid.DataConnection.Count, "ItemsSource was not set from the original DataContext");
dataGrid.DataContext = stringsContainer2;
});
this.EnqueueYieldThread();
this.EnqueueCallback(delegate
{
Assert.AreEqual(stringsContainer2.Strings, dataGrid.ItemsSource, "ItemsSource did not change along with the DataContext");
Assert.AreEqual(5, dataGrid.DataConnection.Count, "ItemsSource did not change along with the DataContext");
});
this.EnqueueTestComplete();
}
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:33,代码来源:ItemsSource.cs
示例6: AutoGenerateOnResetForListOfObjects
public void AutoGenerateOnResetForListOfObjects()
{
DataGrid dataGrid = new DataGrid();
Assert.IsNotNull(dataGrid);
dataGrid.Width = 350;
dataGrid.Height = 250;
_loaded = false;
dataGrid.Loaded += new RoutedEventHandler(DataGrid_Loaded);
DataSourceINCC dataSource = new DataSourceINCC();
dataGrid.ItemsSource = dataSource;
TestPanel.Children.Add(dataGrid);
EnqueueConditional(delegate { return _loaded; });
this.EnqueueYieldThread();
EnqueueCallback(delegate
{
dataSource.Add(new Customer());
dataSource.Add(new Customer());
dataSource.Add(new Customer());
dataSource.Add(new Customer());
dataSource.RaiseReset();
});
this.EnqueueYieldThread();
EnqueueCallback(delegate
{
Assert.IsTrue(dataGrid.Columns.Count > 0);
Assert.IsTrue(dataGrid.DisplayData.FirstScrollingSlot == 0);
Assert.IsTrue(dataGrid.DisplayData.LastScrollingSlot == 3);
});
EnqueueTestComplete();
}
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:34,代码来源:DataGridDdsTest.cs
示例7: DataGrid_AutomationPeer
public void DataGrid_AutomationPeer()
{
DataGrid dataGrid = new DataGrid();
Assert.IsNotNull(dataGrid);
isLoaded = false;
dataGrid.Width = 350;
dataGrid.Height = 250;
dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);
DataGridAutomationPeer peer = ((DataGridAutomationPeer)DataGridAutomationPeer.CreatePeerForElement(dataGrid));
Assert.IsNotNull(peer);
TestPanel.Children.Add(dataGrid);
EnqueueConditional(delegate { return isLoaded; });
this.EnqueueYieldThread();
EnqueueCallback(delegate
{
Assert.AreEqual(dataGrid.Height, peer.GetBoundingRectangle().Height, "Incorrect BoundingRectangle.Height value");
Assert.AreEqual(dataGrid.Width, peer.GetBoundingRectangle().Width, "Incorrect BoundingRectangle.Width value");
Assert.AreEqual(dataGrid.GetType().Name, peer.GetClassName(), "Incorrect ClassName value");
Assert.AreEqual(Automation.Peers.AutomationControlType.DataGrid, peer.GetAutomationControlType(), "Incorrect ControlType value");
Assert.AreEqual(true, peer.IsContentElement(), "Incorrect IsContentElement value");
Assert.AreEqual(true, peer.IsControlElement(), "Incorrect IsControlElement value");
Assert.AreEqual(true, peer.IsKeyboardFocusable(), "Incorrect IsKeyBoardFocusable value");
Assert.IsNotNull(peer.GetPattern(PatternInterface.Grid), "Incorrect GetPattern result for PatternInterface.Grid");
Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "Incorrect GetPattern result for PatternInterface.Scroll");
Assert.IsNotNull(peer.GetPattern(PatternInterface.Selection), "Incorrect GetPattern result for PatternInterface.Selection");
Assert.IsNotNull(peer.GetPattern(PatternInterface.Table), "Incorrect GetPattern result for PatternInterface.Table");
Assert.IsNotNull(peer.GetChildren(), "GetChildren should never return null");
});
EnqueueTestComplete();
}
开发者ID:dfr0,项目名称:moon,代码行数:34,代码来源:DataGridAutomationTest.cs
示例8: CreateCell
public virtual FrameworkElement CreateCell(DataGrid grid, CellType cellType, CellRange rng)
{
// cell border
var bdr = CreateCellBorder(grid, cellType, rng);
// bottom right cells have no content
if (!rng.IsValid)
{
return bdr;
}
// bind/customize cell by type
switch (cellType)
{
case CellType.Cell:
CreateCellContent(grid, bdr, rng);
break;
case CellType.ColumnHeader:
CreateColumnHeaderContent(grid, bdr, rng);
break;
}
// done
return bdr;
}
开发者ID:GJian,项目名称:UWP-master,代码行数:26,代码来源:CellFactory.cs
示例9: getControllerGrid
public DataGrid<UspController> getControllerGrid()
{
DataGrid<UspController> result = new DataGrid<UspController>();
result.rows = systemService.getControllers().ToList();
result.total = result.rows.Count;
return result;
}
开发者ID:zsjforgithub,项目名称:usp-zsj-01-15,代码行数:7,代码来源:SystemBll.cs
示例10: DisturbedSites
//---------------------------------------------------------------------
static DisturbedSites()
{
// columns: 123456789
string[] rows = new string[]{ "---------", // row 1
"---aaDa--", // row 2
"--aDDaa--", // row 3
"--aaaaaa-", // row 4
"-aaa--DD-", // row 5
"-Da---aaa", // row 6
"--aa--D--"}; // row 7
bool[,] array = Bool.Make2DimArray(rows, "aD");
int rowCount = array.GetLength(0);
int colCount = array.GetLength(1);
DataGrid<EcoregionCode> grid = new DataGrid<EcoregionCode>(rowCount, colCount);
for (int row = 1; row <= rowCount; row++) {
for (int col = 1; col <= colCount; col++) {
if (array[row-1, col-1])
grid[row, col] = new EcoregionCode(1, true);
else
grid[row, col] = new EcoregionCode(0, false);
}
}
mixedLandscape = new Landscape(grid, 1);
List<Location> locList = new List<Location>();
foreach (ActiveSite site in mixedLandscape) {
int row = site.Location.Row;
int column = site.Location.Column;
if (rows[row-1][column-1] == 'D')
locList.Add(site.Location);
}
locations = locList.ToArray();
}
开发者ID:LANDIS-II-Foundation,项目名称:Library-Succession,代码行数:34,代码来源:DisturbedSites.cs
示例11: MainForm
public MainForm ()
{
_dataGrid = new DataGrid ();
_column = new DataGridTextBoxColumn ();
SuspendLayout ();
((ISupportInitialize) (_dataGrid)).BeginInit ();
//
// _dataGrid
//
_dataGrid.TableStyles.Add (new DataGridTableStyle ());
_dataGrid.TableStyles [0].GridColumnStyles.Add (_column);
_dataGrid.Location = new Point (12, 115);
_dataGrid.Size = new Size (268, 146);
_dataGrid.TabIndex = 0;
//
// _column
//
_column.HeaderText = "Column";
//
// MainForm
//
ClientSize = new Size (292, 273);
Controls.Add (_dataGrid);
((ISupportInitialize) (_dataGrid)).EndInit ();
ResumeLayout (false);
Load += new EventHandler (MainForm_Load);
}
开发者ID:mono,项目名称:gert,代码行数:27,代码来源:MainForm.cs
示例12: Init
public void Init()
{
string[] rows = new string[] { "....X..",
"...XX.X",
".......",
"...XXX.",
"X.X.X.X",
"XXXXXXX" };
bool [,] activeSites = Bool.Make2DimArray(rows, "X");
mixedGrid = new DataGrid<bool>(activeSites);
mixedMap = new ActiveSiteMap(mixedGrid);
bool found_1stActive = false;
bool found_1stInactive = false;
for (uint row = 1; row <= mixedGrid.Rows; ++row) {
for (uint column = 1; column <= mixedGrid.Columns; ++column) {
if (mixedGrid[row, column]) {
if (! found_1stActive) {
mixed_1stActive = new Location(row, column);
found_1stActive = true;
}
}
else {
if (! found_1stInactive) {
mixed_1stInactive = new Location(row, column);
found_1stInactive = true;
}
}
}
}
}
开发者ID:LANDIS-II-Foundation,项目名称:Libraries,代码行数:31,代码来源:ActiveSiteMap_Test.cs
示例13: RunSelectBackGroundTemplateBeitraege
private void RunSelectBackGroundTemplateBeitraege ()
{
Grid RootGrid = m_XAMLHandler.CreateGrid (new int[] {1, 1, 1}, new int[] {1, 10, 1});
m_XAMLHandler.SetMinMaxHeight (RootGrid, new int[] {0, 2}, 25);
this.Content = RootGrid;
DataSet Beitraege = m_DataBase.GetBeitraege (Von, Bis);
DataGrid PossibleBackGroundBeitraegeDataGrid = new DataGrid ();
PossibleBackGroundBeitraegeDataGrid.AutoGenerateColumns = true;
PossibleBackGroundBeitraegeDataGrid.AutoGeneratedColumns +=
new EventHandler (PossibleBackGroundBeitraegeDataGrid_AutoGeneratedColumns);
PossibleBackGroundBeitraegeDataGrid.ItemsSource = Beitraege.Tables ["BeitraegeImZeitraum"].DefaultView;
(PossibleBackGroundBeitraegeDataGrid.ItemsSource as DataView).RowFilter = "BeitragsTyp = 'ExternesProgramm'";
PossibleBackGroundBeitraegeDataGrid.MouseDoubleClick +=
new MouseButtonEventHandler (PossibleBackGroundBeitraegeDataGrid_MouseDoubleClick);
RootGrid.Children.Add (PossibleBackGroundBeitraegeDataGrid);
Grid.SetRow (PossibleBackGroundBeitraegeDataGrid, 1);
Grid.SetColumn(PossibleBackGroundBeitraegeDataGrid, 0);
Grid.SetColumnSpan (PossibleBackGroundBeitraegeDataGrid, 3);
Button CancelButton = new Button ();
CancelButton.Content = "Abbrechen";
CancelButton.Click += new RoutedEventHandler (CancelButton_Click);
RootGrid.Children.Add (CancelButton);
Grid.SetRow (CancelButton, 2);
Grid.SetColumn (CancelButton, 2);
Button SelectButton = new Button ();
SelectButton.Content = "Auswählen";
SelectButton.Click += new RoutedEventHandler (SelectButton_Click);
RootGrid.Children.Add (SelectButton);
SelectButton.Tag = PossibleBackGroundBeitraegeDataGrid;
Grid.SetRow (SelectButton, 2);
Grid.SetColumn (SelectButton, 1);
}
开发者ID:heinzsack,项目名称:DEV,代码行数:35,代码来源:HandleBeitraege.xaml.cs
示例14: ApplyProperties
protected override void ApplyProperties(CellDefinition cd, DataGrid owner, CellRef cell, PropertyDefinition pd, object item)
{
base.ApplyProperties(cd, owner, cell, pd, item);
cd.IsEnabledBindingSource = this.isItemEnabledSource;
cd.IsEnabledBindingParameter = "yes";
cd.IsEnabledBindingPath = owner.Operator.GetBindingPath(owner, cell);
}
开发者ID:Mitch-Connor,项目名称:PropertyTools,代码行数:7,代码来源:IsEnabledBindingSourceExample.xaml.cs
示例15: binddatagrid
//=================================================
//功能描述:对DATAGRIG进行数据绑定,无排序
//输入参数:sql,查询的SQL语句;dg,需要绑定的DATAGRID控件
//返回值:无
//时间:2013.08.20
//=================================================
public static void binddatagrid(string sql, DataGrid dg)
{
DataSet ds = getdataset(sql);
dg.DataSource = ds.Tables[0].DefaultView;
closeConnection();
dg.DataBind();
}
开发者ID:uwitec,项目名称:baihuibaihui,代码行数:14,代码来源:DB.cs
示例16: Init
public void Init()
{
EcoregionCode[,] array = new EcoregionCode[0,0];
DataGrid<EcoregionCode> grid = new DataGrid<EcoregionCode>(array);
landscape = new Landscape(grid, 1);
siteVarRegistry = new SiteVarRegistry();
}
开发者ID:LANDIS-II-Foundation,项目名称:Libraries,代码行数:8,代码来源:SiteVarRegistry_Test.cs
示例17: Init
public void Init()
{
bool[,] array = new bool[0,0];
DataGrid<bool> grid = new DataGrid<bool>(array);
landscape = new Landscape(grid);
siteVarRegistry = new SiteVarRegistry();
}
开发者ID:LANDIS-II-Foundation,项目名称:Core-Model,代码行数:8,代码来源:SiteVarRegistry_Test.cs
示例18: getPrivilegeGrid
public DataGrid<UspPrivilege> getPrivilegeGrid()
{
//UpdatePrivilege();
DataGrid<UspPrivilege> result = new DataGrid<UspPrivilege>();
result.rows = systemService.getPrivileges();
result.total = result.rows.Count;
return result;
}
开发者ID:zsjforgithub,项目名称:usp-zsj-01-15,代码行数:8,代码来源:SystemBll.cs
示例19: DataGridAutomationPeer
/// <summary>
/// Default contructor
/// </summary>
/// <param name="owner">DataGrid</param>
public DataGridAutomationPeer(DataGrid owner)
: base(owner)
{
if (owner == null)
{
throw new ArgumentNullException("owner");
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:12,代码来源:DataGridAutomationPeer.cs
示例20: getMenuGrid
public DataGrid<UspMenuItem> getMenuGrid()
{
UpdateMenu();
DataGrid<UspMenuItem> result = new DataGrid<UspMenuItem>();
result.rows = systemService.getMenuItems();
result.total = result.rows.Count;
return result;
}
开发者ID:zsjforgithub,项目名称:usp-zsj-01-15,代码行数:8,代码来源:SystemBll.cs
注:本文中的DataGrid类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论