Skip to content

Commit 615b20b

Browse files
committed
WF-19394 - Sample added.
1 parent 9608f61 commit 615b20b

File tree

10 files changed

+1199
-0
lines changed

10 files changed

+1199
-0
lines changed

GridWF_C#/App.ico

1.05 KB
Binary file not shown.

GridWF_C#/AssemblyInfo.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#region Copyright Syncfusion Inc. 2001 - 2005
2+
//
3+
// Copyright Syncfusion Inc. 2001 - 2005. All rights reserved.
4+
//
5+
// Use of this code is subject to the terms of our license.
6+
// A copy of the current license can be obtained at any time by e-mailing
7+
// licensing@syncfusion.com. Any infringement will be prosecuted under
8+
// applicable laws.
9+
//
10+
#endregion
11+
12+
using System.Reflection;
13+
using System.Runtime.CompilerServices;
14+
15+
//
16+
// General Information about an assembly is controlled through the following
17+
// set of attributes. Change these attribute values to modify the information
18+
// associated with an assembly.
19+
//
20+
[assembly: AssemblyTitle("")]
21+
[assembly: AssemblyDescription("")]
22+
[assembly: AssemblyConfiguration("")]
23+
[assembly: AssemblyCompany("")]
24+
[assembly: AssemblyProduct("")]
25+
[assembly: AssemblyCopyright("")]
26+
[assembly: AssemblyTrademark("")]
27+
[assembly: AssemblyCulture("")]
28+
29+
//
30+
// Version information for an assembly consists of the following four values:
31+
//
32+
// Major Version
33+
// Minor Version
34+
// Build Number
35+
// Revision
36+
//
37+
// You can specify all the values or you can default the Revision and Build Numbers
38+
// by using the '*' as shown below:
39+
40+
[assembly: AssemblyVersion("1.0.*")]
41+
42+
//
43+
// In order to sign your assembly you must specify a key to use. Refer to the
44+
// Microsoft .NET Framework documentation for more information on assembly signing.
45+
//
46+
// Use the attributes below to control which key is used for signing.
47+
//
48+
// Notes:
49+
// (*) If no key is specified, the assembly is not signed.
50+
// (*) KeyName refers to a key that has been installed in the Crypto Service
51+
// Provider (CSP) on your machine. KeyFile refers to a file which contains
52+
// a key.
53+
// (*) If the KeyFile and the KeyName values are both specified, the
54+
// following processing occurs:
55+
// (1) If the KeyName can be found in the CSP, that key is used.
56+
// (2) If the KeyName does not exist and the KeyFile does exist, the key
57+
// in the KeyFile is installed into the CSP and used.
58+
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
59+
// When specifying the KeyFile, the location of the KeyFile should be
60+
// relative to the project output directory which is
61+
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
62+
// located in the project directory, you would specify the AssemblyKeyFile
63+
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
64+
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
65+
// documentation for more information on this.
66+
//
67+
[assembly: AssemblyDelaySign(false)]
68+
[assembly: AssemblyKeyFile("")]
69+
[assembly: AssemblyKeyName("")]

GridWF_C#/Form1.cs

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
#region Copyright Syncfusion Inc. 2001 - 2005
2+
//
3+
// Copyright Syncfusion Inc. 2001 - 2005. All rights reserved.
4+
//
5+
// Use of this code is subject to the terms of our license.
6+
// A copy of the current license can be obtained at any time by e-mailing
7+
// licensing@syncfusion.com. Any infringement will be prosecuted under
8+
// applicable laws.
9+
//
10+
#endregion
11+
12+
using System;
13+
using System.Drawing;
14+
using System.Collections;
15+
using System.Collections.Specialized;
16+
using System.ComponentModel;
17+
using System.Windows.Forms;
18+
using System.Data;
19+
using Syncfusion.Windows.Forms.Grid;
20+
using Syncfusion.ComponentModel;
21+
22+
namespace GridPopulationSample
23+
{
24+
/// <summary>
25+
/// Summary description for Form1.
26+
/// </summary>
27+
public class Form1 : System.Windows.Forms.Form
28+
{
29+
private Syncfusion.Windows.Forms.Grid.GridControl gridControl1;
30+
31+
private DataTable dt;
32+
private int numArrayRows;
33+
private int numArrayCols;
34+
private System.Windows.Forms.Button button1;
35+
/// <summary>
36+
/// Required designer variable.
37+
/// </summary>
38+
private System.ComponentModel.Container components = null;
39+
40+
public Form1()
41+
{
42+
//
43+
// Required for Windows Form Designer support
44+
//
45+
InitializeComponent();
46+
47+
this.SetUpData();
48+
49+
}
50+
51+
/// <summary>
52+
/// Clean up any resources being used.
53+
/// </summary>
54+
protected override void Dispose( bool disposing )
55+
{
56+
if( disposing )
57+
{
58+
if (components != null)
59+
{
60+
components.Dispose();
61+
}
62+
}
63+
base.Dispose( disposing );
64+
}
65+
66+
#region Windows Form Designer generated code
67+
/// <summary>
68+
/// Required method for Designer support - do not modify
69+
/// the contents of this method with the code editor.
70+
/// </summary>
71+
private void InitializeComponent()
72+
{
73+
this.gridControl1 = new Syncfusion.Windows.Forms.Grid.GridControl();
74+
this.button1 = new System.Windows.Forms.Button();
75+
((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit();
76+
this.SuspendLayout();
77+
//
78+
// gridControl1
79+
//
80+
this.gridControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
81+
| System.Windows.Forms.AnchorStyles.Left)
82+
| System.Windows.Forms.AnchorStyles.Right)));
83+
this.gridControl1.DefaultColWidth = 75;
84+
this.gridControl1.DefaultGridBorderStyle = Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid;
85+
this.gridControl1.ForeColor = System.Drawing.SystemColors.ControlText;
86+
this.gridControl1.Location = new System.Drawing.Point(8, 8);
87+
this.gridControl1.Name = "gridControl1";
88+
this.gridControl1.RightToLeft = System.Windows.Forms.RightToLeft.No;
89+
this.gridControl1.RowCount = 1000;
90+
this.gridControl1.RowHeightEntries.AddRange(new Syncfusion.Windows.Forms.Grid.GridRowHeight[] {
91+
new Syncfusion.Windows.Forms.Grid.GridRowHeight(0, 24)});
92+
this.gridControl1.Size = new System.Drawing.Size(808, 240);
93+
this.gridControl1.SmartSizeBox = false;
94+
this.gridControl1.TabIndex = 0;
95+
this.gridControl1.ThemesEnabled = true;
96+
//
97+
// button1
98+
//
99+
this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
100+
this.button1.Location = new System.Drawing.Point(328, 264);
101+
this.button1.Name = "button1";
102+
this.button1.Size = new System.Drawing.Size(128, 23);
103+
this.button1.TabIndex = 1;
104+
this.button1.Text = "Wire/Unwire FilterBar";
105+
this.button1.Click += new System.EventHandler(this.button1_Click);
106+
//
107+
// Form1
108+
//
109+
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
110+
this.ClientSize = new System.Drawing.Size(824, 294);
111+
this.Controls.Add(this.button1);
112+
this.Controls.Add(this.gridControl1);
113+
this.Name = "Form1";
114+
this.Text = "Form1";
115+
this.Load += new System.EventHandler(this.Form1_Load);
116+
((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit();
117+
this.ResumeLayout(false);
118+
119+
}
120+
#endregion
121+
122+
/// <summary>
123+
/// The main entry point for the application.
124+
/// </summary>
125+
[STAThread]
126+
public static void Main()
127+
{
128+
Application.Run(new Form1());
129+
}
130+
131+
132+
private void SetUpData()
133+
{
134+
this.Cursor = Cursors.WaitCursor;
135+
this.numArrayCols = 10;
136+
this.numArrayRows = 10;
137+
138+
this.dt = new DataTable();
139+
for(int i =0;i<this.numArrayCols;i++)
140+
{
141+
DataColumn col = new DataColumn(string.Format("Column {0}",Convert.ToChar(65+i)));
142+
dt.Columns.Add(col);
143+
}
144+
145+
Random r = new Random();
146+
for (int i = 0; i < this.numArrayRows; ++i)
147+
{
148+
DataRow row= dt.NewRow();
149+
for(int j = 0; j < this.numArrayCols; ++j)
150+
{
151+
int ch = r.Next(87);
152+
ch = ch>65?ch:65;
153+
row[j] = (Convert.ToChar(ch));
154+
}
155+
this.dt.Rows.Add(row);
156+
}
157+
this.Cursor = Cursors.Arrow;
158+
}
159+
160+
161+
162+
GridControlFilterBar filterBar;
163+
164+
private void Form1_Load(object sender, System.EventArgs e)
165+
{
166+
filterBar = new GridControlFilterBar();
167+
filterBar.WireGrid(this.gridControl1,this.dt);
168+
169+
this.gridControl1.ResetVolatileData();
170+
171+
this.gridControl1.QueryCellInfo += new GridQueryCellInfoEventHandler(QueryCellInfoHandler);
172+
this.gridControl1.QueryColCount += new GridRowColCountEventHandler(GridQueryColCount);
173+
this.gridControl1.QueryRowCount += new GridRowColCountEventHandler(GridQueryRowCount);
174+
this.gridControl1.SaveCellInfo += new GridSaveCellInfoEventHandler(SaveCellInfoHandler);
175+
176+
for(int i = 1;i<=10;i++)
177+
this.gridControl1[0,i].Text = string.Format("Column {0}",Convert.ToChar(64+i));
178+
179+
this.gridControl1.Refresh();
180+
}
181+
182+
183+
#region Virtual Mode
184+
185+
private void QueryCellInfoHandler(object sender, GridQueryCellInfoEventArgs e)
186+
{
187+
int filterCheck = 0;
188+
if(filterBar.IsWired)
189+
filterCheck = 1;
190+
if(e.ColIndex > 0 && e.RowIndex > 0 && e.RowIndex != filterCheck)
191+
{
192+
e.Style.CellValue = this.dt.DefaultView[e.RowIndex-(1+filterCheck)][e.ColIndex - 1];
193+
e.Handled = true;
194+
}
195+
else
196+
if(e.ColIndex == 0 && e.RowIndex>0)
197+
{
198+
e.Style.Text = " ";
199+
}
200+
}
201+
private void SaveCellInfoHandler(object sender, GridSaveCellInfoEventArgs e)
202+
{
203+
if(e.ColIndex > 0 && e.RowIndex > 1)
204+
{
205+
this.dt.DefaultView[e.RowIndex-2][e.ColIndex - 1] = e.Style.CellValue;
206+
e.Handled = true;
207+
}
208+
}
209+
private void GridQueryColCount(object sender, GridRowColCountEventArgs e)
210+
{
211+
e.Count = this.numArrayCols;
212+
e.Handled = true;
213+
}
214+
215+
private void GridQueryRowCount(object sender, GridRowColCountEventArgs e)
216+
{
217+
e.Count = filterBar.RowCount;
218+
e.Handled = true;
219+
}
220+
221+
#endregion
222+
223+
private void button1_Click(object sender, System.EventArgs e)
224+
{
225+
if(this.filterBar.IsWired)
226+
this.filterBar.UnwireGrid();
227+
else
228+
this.filterBar.WireGrid(this.gridControl1,this.dt);
229+
230+
}
231+
232+
}
233+
234+
}

0 commit comments

Comments
 (0)