Permalink
Browse files

Pedro Martinez Julia DataGridView samples

svn path=/trunk/winforms/; revision=52746
  • Loading branch information...
1 parent f71de77 commit 398bbd66bd0e71b9063358416de65b7c9a89b7ff Jordi Mas i Hernandez committed Nov 8, 2005
@@ -0,0 +1,116 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DataGridViewAdvancedBorderStyleSample
+{
+ class Form1 : Form
+ {
+ public static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.Run(new Form1());
+ }
+
+ public Form1()
+ {
+ //this.AutoSize = true;
+ DataGridView dgv = new CustomDataGridView();
+ dgv.Size = new Size(500,500);
+ //this.Controls.Add(new CustomDataGridView());
+ this.Controls.Add(dgv);
+ this.Text = "DataGridView advanced border styles demo";
+ }
+ }
+
+ public class CustomDataGridView : DataGridView
+ {
+ public CustomDataGridView()
+ {
+ this.RowTemplate = new DataGridViewCustomRow();
+ this.Columns.Add(new DataGridViewCustomColumn());
+ this.Columns.Add(new DataGridViewCustomColumn());
+ this.Columns.Add(new DataGridViewCustomColumn());
+ this.RowCount = 4;
+ this.EnableHeadersVisualStyles = false;
+ this.AutoSize = true;
+ }
+
+ public override DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle
+ {
+ get
+ {
+ DataGridViewAdvancedBorderStyle newStyle =
+ new DataGridViewAdvancedBorderStyle();
+ newStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
+ newStyle.Left = DataGridViewAdvancedCellBorderStyle.None;
+ newStyle.Bottom = DataGridViewAdvancedCellBorderStyle.Outset;
+ newStyle.Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+ return newStyle;
+ }
+ }
+
+ public override DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle(
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
+ bool firstDisplayedColumn,
+ bool lastVisibleColumn)
+ {
+ // Customize the left border of the first column header and the
+ // bottom border of all the column headers. Use the input style for
+ // all other borders.
+ dataGridViewAdvancedBorderStylePlaceHolder.Left = firstDisplayedColumn ?
+ DataGridViewAdvancedCellBorderStyle.OutsetDouble :
+ DataGridViewAdvancedCellBorderStyle.None;
+ dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
+ DataGridViewAdvancedCellBorderStyle.Single;
+
+ dataGridViewAdvancedBorderStylePlaceHolder.Right =
+ dataGridViewAdvancedBorderStyleInput.Right;
+ dataGridViewAdvancedBorderStylePlaceHolder.Top =
+ dataGridViewAdvancedBorderStyleInput.Top;
+
+ return dataGridViewAdvancedBorderStylePlaceHolder;
+ }
+ }
+
+ public class DataGridViewCustomColumn : DataGridViewColumn
+ {
+ public DataGridViewCustomColumn()
+ {
+ this.CellTemplate = new DataGridViewCustomCell();
+ }
+ }
+
+ public class DataGridViewCustomCell : DataGridViewTextBoxCell
+ {
+ }
+
+ public class DataGridViewCustomRow : DataGridViewRow
+ {
+ public override DataGridViewAdvancedBorderStyle AdjustRowHeaderBorderStyle(
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
+ bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded,
+ bool isFirstDisplayedRow,
+ bool isLastDisplayedRow)
+ {
+ // Customize the top border of the first row header and the
+ // right border of all the row headers. Use the input style for
+ // all other borders.
+ dataGridViewAdvancedBorderStylePlaceHolder.Top = isFirstDisplayedRow ?
+ DataGridViewAdvancedCellBorderStyle.InsetDouble :
+ DataGridViewAdvancedCellBorderStyle.None;
+ dataGridViewAdvancedBorderStylePlaceHolder.Right =
+ DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+
+ dataGridViewAdvancedBorderStylePlaceHolder.Left =
+ dataGridViewAdvancedBorderStyleInput.Left;
+ dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
+ dataGridViewAdvancedBorderStyleInput.Bottom;
+
+ return dataGridViewAdvancedBorderStylePlaceHolder;
+ }
+ }
+}
@@ -0,0 +1,116 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DataGridViewAdvancedBorderStyleSample
+{
+ class Form1 : Form
+ {
+ public static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.Run(new Form1());
+ }
+
+ public Form1()
+ {
+ //this.AutoSize = true;
+ DataGridView dgv = new CustomDataGridView();
+ dgv.Size = new Size(500,500);
+ //this.Controls.Add(new CustomDataGridView());
+ this.Controls.Add(dgv);
+ this.Text = "DataGridView advanced border styles demo";
+ }
+ }
+
+ public class CustomDataGridView : DataGridView
+ {
+ public CustomDataGridView()
+ {
+ this.RowTemplate = new DataGridViewCustomRow();
+ this.Columns.Add(new DataGridViewCustomColumn());
+ this.Columns.Add(new DataGridViewCustomColumn());
+ this.Columns.Add(new DataGridViewCustomColumn());
+ this.RowCount = 4;
+ this.EnableHeadersVisualStyles = false;
+ this.AutoSize = true;
+ }
+
+ public override DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle
+ {
+ get
+ {
+ DataGridViewAdvancedBorderStyle newStyle =
+ new DataGridViewAdvancedBorderStyle();
+ newStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
+ newStyle.Left = DataGridViewAdvancedCellBorderStyle.None;
+ newStyle.Bottom = DataGridViewAdvancedCellBorderStyle.Outset;
+ newStyle.Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+ return newStyle;
+ }
+ }
+
+ public override DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle(
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
+ bool firstDisplayedColumn,
+ bool lastVisibleColumn)
+ {
+ // Customize the left border of the first column header and the
+ // bottom border of all the column headers. Use the input style for
+ // all other borders.
+ dataGridViewAdvancedBorderStylePlaceHolder.Left = firstDisplayedColumn ?
+ DataGridViewAdvancedCellBorderStyle.OutsetDouble :
+ DataGridViewAdvancedCellBorderStyle.None;
+ dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
+ DataGridViewAdvancedCellBorderStyle.Single;
+
+ dataGridViewAdvancedBorderStylePlaceHolder.Right =
+ dataGridViewAdvancedBorderStyleInput.Right;
+ dataGridViewAdvancedBorderStylePlaceHolder.Top =
+ dataGridViewAdvancedBorderStyleInput.Top;
+
+ return dataGridViewAdvancedBorderStylePlaceHolder;
+ }
+ }
+
+ public class DataGridViewCustomColumn : DataGridViewColumn
+ {
+ public DataGridViewCustomColumn()
+ {
+ this.CellTemplate = new DataGridViewCustomCell();
+ }
+ }
+
+ public class DataGridViewCustomCell : DataGridViewTextBoxCell
+ {
+ }
+
+ public class DataGridViewCustomRow : DataGridViewRow
+ {
+ public override DataGridViewAdvancedBorderStyle AdjustRowHeaderBorderStyle(
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
+ DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
+ bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded,
+ bool isFirstDisplayedRow,
+ bool isLastDisplayedRow)
+ {
+ // Customize the top border of the first row header and the
+ // right border of all the row headers. Use the input style for
+ // all other borders.
+ dataGridViewAdvancedBorderStylePlaceHolder.Top = isFirstDisplayedRow ?
+ DataGridViewAdvancedCellBorderStyle.InsetDouble :
+ DataGridViewAdvancedCellBorderStyle.None;
+ dataGridViewAdvancedBorderStylePlaceHolder.Right =
+ DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+
+ dataGridViewAdvancedBorderStylePlaceHolder.Left =
+ dataGridViewAdvancedBorderStyleInput.Left;
+ dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
+ dataGridViewAdvancedBorderStyleInput.Bottom;
+
+ return dataGridViewAdvancedBorderStylePlaceHolder;
+ }
+ }
+}
@@ -0,0 +1,38 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Collections;
+using System.Data;
+
+public class Form1 : Form {
+
+ public Form1 () {
+ //this.AutoSize = true;
+ DataGridView dgv = new DataGridView();
+ //dgv.Size = new Size(500,250);
+ dgv.Location = new Point(10,10);
+ dgv.EnableHeadersVisualStyles = false;
+ dgv.AutoSize = true;
+ this.Controls.Add(dgv);
+ this.Text = "DataGridView advanced border styles demo";
+ dgv.DataSource = GetDataTable();
+ }
+
+ public DataTable GetDataTable () {
+ DataTable result = new DataTable();
+ result.Columns.Add(new DataColumn("NAME"));
+ result.Columns.Add(new DataColumn("NUMBER"));
+ for (int i = 0; i < 10; i++) {
+ DataRow row = result.NewRow();
+ row["NAME"] = "Name " + i.ToString();
+ row["NUMBER"] = i.ToString();
+ result.Rows.Add(row);
+ }
+ return result;
+ }
+
+ public static void Main() {
+ Application.Run(new Form1());
+ }
+
+}
@@ -0,0 +1,34 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Collections;
+using System.Data;
+
+public class Form1 : Form {
+
+ public Form1 () {
+ //this.AutoSize = true;
+ DataGridView dgv = new DataGridView();
+ //dgv.Size = new Size(500,250);
+ dgv.Location = new Point(10,10);
+ dgv.EnableHeadersVisualStyles = false;
+ dgv.AutoSize = true;
+ this.Controls.Add(dgv);
+ this.Text = "DataGridView advanced border styles demo";
+ dgv.DataSource = GetDataTable();
+ }
+
+ public DataTable GetDataTable () {
+ DataSet ds = new DataSet();
+ System.IO.FileStream fs = new System.IO.FileStream("programes.xml", System.IO.FileMode.Open);
+ System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fs);
+ ds.ReadXml(reader);
+ reader.Close();
+ return ds.Tables["programes"];
+ }
+
+ public static void Main() {
+ Application.Run(new Form1());
+ }
+
+}
@@ -0,0 +1,55 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Collections;
+
+public class DataElement {
+
+ private string name;
+ private int val;
+
+ public DataElement () {
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public int Val {
+ get { return val; }
+ set { val = value; }
+ }
+
+}
+
+public class Form1 : Form {
+
+ public Form1 () {
+ //this.AutoSize = true;
+ DataGridView dgv = new DataGridView();
+ //dgv.Size = new Size(500,250);
+ dgv.Location = new Point(10,10);
+ dgv.EnableHeadersVisualStyles = false;
+ dgv.AutoSize = true;
+ this.Controls.Add(dgv);
+ this.Text = "DataGridView advanced border styles demo";
+ dgv.DataSource = GetList();
+ }
+
+ public IList GetList () {
+ ArrayList result = new ArrayList();
+ for (int i = 0; i < 10; i++) {
+ DataElement element = new DataElement();
+ element.Name = "Name " + i.ToString();
+ element.Val = i;
+ result.Add(element);
+ }
+ return result;
+ }
+
+ public static void Main() {
+ Application.Run(new Form1());
+ }
+
+}
Oops, something went wrong.

0 comments on commit 398bbd6

Please sign in to comment.