GridControl.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. using System;
  2. using System.ComponentModel;
  3. using System.Windows.Forms;
  4. using System.Drawing;
  5. using System.Drawing.Design;
  6. using FastReport.Utils;
  7. using FastReport.Data;
  8. namespace FastReport.Dialog
  9. {
  10. /// <summary>
  11. /// Displays data in a customizable grid.
  12. /// Wraps the <see cref="System.Windows.Forms.DataGridView"/> control.
  13. /// </summary>
  14. public partial class GridControl : DialogControl, IParent
  15. {
  16. private DataGridView dataGridView;
  17. private GridControlColumnCollection columns;
  18. private DataSourceBase dataSource;
  19. #region Properties
  20. /// <summary>
  21. /// Gets an internal <b>DataGridView</b>.
  22. /// </summary>
  23. [Browsable(false)]
  24. public DataGridView DataGridView
  25. {
  26. get { return dataGridView; }
  27. }
  28. /// <summary>
  29. /// Gets or sets the data source that the DataGridView is displaying data for.
  30. /// </summary>
  31. [Category("Data")]
  32. public DataSourceBase DataSource
  33. {
  34. get { return dataSource; }
  35. set
  36. {
  37. if (dataSource != value)
  38. {
  39. if (dataSource != null)
  40. dataSource.Disposed -= new EventHandler(DataSource_Disposed);
  41. if (value != null)
  42. value.Disposed += new EventHandler(DataSource_Disposed);
  43. }
  44. dataSource = value;
  45. }
  46. }
  47. /// <summary>
  48. /// Gets or sets a value indicating whether the option to add rows is displayed to the user.
  49. /// Wraps the <see cref="System.Windows.Forms.DataGridView.AllowUserToAddRows"/> property.
  50. /// </summary>
  51. [DefaultValue(false)]
  52. [Category("Behavior")]
  53. public bool AllowUserToAddRows
  54. {
  55. get { return DataGridView.AllowUserToAddRows; }
  56. set { DataGridView.AllowUserToAddRows = value; }
  57. }
  58. /// <summary>
  59. /// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
  60. /// Wraps the <see cref="System.Windows.Forms.DataGridView.AllowUserToDeleteRows"/> property.
  61. /// </summary>
  62. [DefaultValue(false)]
  63. [Category("Behavior")]
  64. public bool AllowUserToDeleteRows
  65. {
  66. get { return DataGridView.AllowUserToDeleteRows; }
  67. set { DataGridView.AllowUserToDeleteRows = value; }
  68. }
  69. /// <summary>
  70. /// Gets or sets the default cell style applied to odd-numbered rows of the DataGridView.
  71. /// Wraps the <see cref="System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyle"/> property.
  72. /// </summary>
  73. [Category("Appearance")]
  74. public DataGridViewCellStyle AlternatingRowsDefaultCellStyle
  75. {
  76. get { return DataGridView.AlternatingRowsDefaultCellStyle; }
  77. set { DataGridView.AlternatingRowsDefaultCellStyle = value; }
  78. }
  79. /// <summary>
  80. /// Gets or sets a value indicating how column widths are determined.
  81. /// Wraps the <see cref="System.Windows.Forms.DataGridView.AutoSizeColumnsMode"/> property.
  82. /// </summary>
  83. [DefaultValue(DataGridViewAutoSizeColumnsMode.None)]
  84. [Category("Layout")]
  85. public DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode
  86. {
  87. get { return DataGridView.AutoSizeColumnsMode; }
  88. set { DataGridView.AutoSizeColumnsMode = value; }
  89. }
  90. /// <summary>
  91. /// Gets or sets a value indicating how row heights are determined.
  92. /// Wraps the <see cref="System.Windows.Forms.DataGridView.AutoSizeRowsMode"/> property.
  93. /// </summary>
  94. [DefaultValue(DataGridViewAutoSizeRowsMode.None)]
  95. [Category("Layout")]
  96. public DataGridViewAutoSizeRowsMode AutoSizeRowsMode
  97. {
  98. get { return DataGridView.AutoSizeRowsMode; }
  99. set { DataGridView.AutoSizeRowsMode = value; }
  100. }
  101. /// <summary>
  102. /// Gets or sets the background color of the DataGridView.
  103. /// Wraps the <see cref="System.Windows.Forms.DataGridView.BackgroundColor"/> property.
  104. /// </summary>
  105. [Category("Appearance")]
  106. [Editor("FastReport.TypeEditors.ColorEditor, FastReport", typeof(UITypeEditor))]
  107. public Color BackgroundColor
  108. {
  109. get { return DataGridView.BackgroundColor; }
  110. set { DataGridView.BackgroundColor = value; }
  111. }
  112. /// <summary>
  113. /// Gets or sets the border style for the DataGridView.
  114. /// Wraps the <see cref="System.Windows.Forms.DataGridView.BorderStyle"/> property.
  115. /// </summary>
  116. [DefaultValue(BorderStyle.FixedSingle)]
  117. [Category("Appearance")]
  118. public BorderStyle BorderStyle
  119. {
  120. get { return DataGridView.BorderStyle; }
  121. set { DataGridView.BorderStyle = value; }
  122. }
  123. /// <summary>
  124. /// Gets the cell border style for the DataGridView.
  125. /// Wraps the <see cref="System.Windows.Forms.DataGridView.CellBorderStyle"/> property.
  126. /// </summary>
  127. [DefaultValue(DataGridViewCellBorderStyle.Single)]
  128. [Category("Appearance")]
  129. public DataGridViewCellBorderStyle CellBorderStyle
  130. {
  131. get { return DataGridView.CellBorderStyle; }
  132. set { DataGridView.CellBorderStyle = value; }
  133. }
  134. /// <summary>
  135. /// Gets the border style applied to the column headers.
  136. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ColumnHeadersBorderStyle"/> property.
  137. /// </summary>
  138. [DefaultValue(DataGridViewHeaderBorderStyle.Raised)]
  139. [Category("Appearance")]
  140. public DataGridViewHeaderBorderStyle ColumnHeadersBorderStyle
  141. {
  142. get { return DataGridView.ColumnHeadersBorderStyle; }
  143. set { DataGridView.ColumnHeadersBorderStyle = value; }
  144. }
  145. /// <summary>
  146. /// Gets or sets the default column header style.
  147. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ColumnHeadersDefaultCellStyle"/> property.
  148. /// </summary>
  149. [Category("Appearance")]
  150. public DataGridViewCellStyle ColumnHeadersDefaultCellStyle
  151. {
  152. get { return DataGridView.ColumnHeadersDefaultCellStyle; }
  153. set { DataGridView.ColumnHeadersDefaultCellStyle = value; }
  154. }
  155. /// <summary>
  156. /// Gets or sets the height, in pixels, of the column headers row.
  157. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ColumnHeadersHeight"/> property.
  158. /// </summary>
  159. [DefaultValue(18)]
  160. [Category("Layout")]
  161. public int ColumnHeadersHeight
  162. {
  163. get { return DataGridView.ColumnHeadersHeight; }
  164. set { DataGridView.ColumnHeadersHeight = value; }
  165. }
  166. /// <summary>
  167. /// Gets or sets a value indicating whether the height of the column headers is adjustable and whether it can be adjusted by the user or is automatically adjusted to fit the contents of the headers.
  168. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ColumnHeadersHeightSizeMode"/> property.
  169. /// </summary>
  170. [DefaultValue(DataGridViewColumnHeadersHeightSizeMode.EnableResizing)]
  171. [Category("Behavior")]
  172. public DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode
  173. {
  174. get { return DataGridView.ColumnHeadersHeightSizeMode; }
  175. set { DataGridView.ColumnHeadersHeightSizeMode = value; }
  176. }
  177. /// <summary>
  178. /// Gets or sets a value indicating whether the column header row is displayed.
  179. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ColumnHeadersVisible"/> property.
  180. /// </summary>
  181. [DefaultValue(true)]
  182. [Category("Appearance")]
  183. public bool ColumnHeadersVisible
  184. {
  185. get { return DataGridView.ColumnHeadersVisible; }
  186. set { DataGridView.ColumnHeadersVisible = value; }
  187. }
  188. /// <summary>
  189. /// Gets the collection of <see cref="GridControlColumn"/> objects that represents the grid columns.
  190. /// </summary>
  191. [Category("Data")]
  192. [Editor("FastReport.TypeEditors.GridControlColumnsEditor, FastReport", typeof(UITypeEditor))]
  193. public GridControlColumnCollection Columns
  194. {
  195. get { return columns; }
  196. }
  197. /// <summary>
  198. /// Gets or sets the default cell style to be applied to the cells in the DataGridView if no other cell style properties are set.
  199. /// Wraps the <see cref="System.Windows.Forms.DataGridView.DefaultCellStyle"/> property.
  200. /// </summary>
  201. [Category("Appearance")]
  202. public DataGridViewCellStyle DefaultCellStyle
  203. {
  204. get { return DataGridView.DefaultCellStyle; }
  205. set { DataGridView.DefaultCellStyle = value; }
  206. }
  207. /// <summary>
  208. /// Gets or sets the color of the grid lines separating the cells of the DataGridView.
  209. /// Wraps the <see cref="System.Windows.Forms.DataGridView.GridColor"/> property.
  210. /// </summary>
  211. [Category("Appearance")]
  212. [Editor("FastReport.TypeEditors.ColorEditor, FastReport", typeof(UITypeEditor))]
  213. public Color GridColor
  214. {
  215. get { return DataGridView.GridColor; }
  216. set { DataGridView.GridColor = value; }
  217. }
  218. /// <summary>
  219. /// Gets or sets a value indicating whether the user is allowed to select more than one cell, row, or column of the DataGridView at a time.
  220. /// Wraps the <see cref="System.Windows.Forms.DataGridView.MultiSelect"/> property.
  221. /// </summary>
  222. [DefaultValue(true)]
  223. [Category("Behavior")]
  224. public bool MultiSelect
  225. {
  226. get { return DataGridView.MultiSelect; }
  227. set { DataGridView.MultiSelect = value; }
  228. }
  229. /// <summary>
  230. /// Gets a value indicating whether the user can edit the cells of the DataGridView control.
  231. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ReadOnly"/> property.
  232. /// </summary>
  233. [DefaultValue(true)]
  234. [Category("Behavior")]
  235. public bool ReadOnly
  236. {
  237. get { return DataGridView.ReadOnly; }
  238. set { DataGridView.ReadOnly = value; }
  239. }
  240. /// <summary>
  241. /// Gets or sets the border style of the row header cells.
  242. /// Wraps the <see cref="System.Windows.Forms.DataGridView.RowHeadersBorderStyle"/> property.
  243. /// </summary>
  244. [DefaultValue(DataGridViewHeaderBorderStyle.Raised)]
  245. [Category("Appearance")]
  246. public DataGridViewHeaderBorderStyle RowHeadersBorderStyle
  247. {
  248. get { return DataGridView.RowHeadersBorderStyle; }
  249. set { DataGridView.RowHeadersBorderStyle = value; }
  250. }
  251. /// <summary>
  252. /// Gets or sets the default style applied to the row header cells.
  253. /// Wraps the <see cref="System.Windows.Forms.DataGridView.RowHeadersDefaultCellStyle"/> property.
  254. /// </summary>
  255. [Category("Appearance")]
  256. public DataGridViewCellStyle RowHeadersDefaultCellStyle
  257. {
  258. get { return DataGridView.RowHeadersDefaultCellStyle; }
  259. set { DataGridView.RowHeadersDefaultCellStyle = value; }
  260. }
  261. /// <summary>
  262. /// Gets or sets a value indicating whether the column that contains row headers is displayed.
  263. /// Wraps the <see cref="System.Windows.Forms.DataGridView.RowHeadersVisible"/> property.
  264. /// </summary>
  265. [DefaultValue(true)]
  266. [Category("Appearance")]
  267. public bool RowHeadersVisible
  268. {
  269. get { return DataGridView.RowHeadersVisible; }
  270. set { DataGridView.RowHeadersVisible = value; }
  271. }
  272. /// <summary>
  273. /// Gets or sets the width, in pixels, of the column that contains the row headers.
  274. /// Wraps the <see cref="System.Windows.Forms.DataGridView.RowHeadersWidth"/> property.
  275. /// </summary>
  276. [DefaultValue(41)]
  277. [Category("Layout")]
  278. public int RowHeadersWidth
  279. {
  280. get { return DataGridView.RowHeadersWidth; }
  281. set { DataGridView.RowHeadersWidth = value; }
  282. }
  283. /// <summary>
  284. /// Gets or sets a value indicating whether the width of the row headers is adjustable and whether it can be adjusted by the user or is automatically adjusted to fit the contents of the headers.
  285. /// Wraps the <see cref="System.Windows.Forms.DataGridView.RowHeadersWidthSizeMode"/> property.
  286. /// </summary>
  287. [DefaultValue(DataGridViewRowHeadersWidthSizeMode.EnableResizing)]
  288. [Category("Behavior")]
  289. public DataGridViewRowHeadersWidthSizeMode RowHeadersWidthSizeMode
  290. {
  291. get { return DataGridView.RowHeadersWidthSizeMode; }
  292. set { DataGridView.RowHeadersWidthSizeMode = value; }
  293. }
  294. /// <summary>
  295. /// Gets or sets the default style applied to the row cells of the DataGridView.
  296. /// Wraps the <see cref="System.Windows.Forms.DataGridView.RowsDefaultCellStyle"/> property.
  297. /// </summary>
  298. [Category("Appearance")]
  299. public DataGridViewCellStyle RowsDefaultCellStyle
  300. {
  301. get { return DataGridView.RowsDefaultCellStyle; }
  302. set { DataGridView.RowsDefaultCellStyle = value; }
  303. }
  304. /// <summary>
  305. /// Gets or sets the type of scroll bars to display for the DataGridView control.
  306. /// Wraps the <see cref="System.Windows.Forms.DataGridView.ScrollBars"/> property.
  307. /// </summary>
  308. [DefaultValue(ScrollBars.Both)]
  309. [Category("Layout")]
  310. public ScrollBars ScrollBars
  311. {
  312. get { return DataGridView.ScrollBars; }
  313. set { DataGridView.ScrollBars = value; }
  314. }
  315. /// <summary>
  316. /// Gets or sets a value indicating how the cells of the DataGridView can be selected.
  317. /// Wraps the <see cref="System.Windows.Forms.DataGridView.SelectionMode"/> property.
  318. /// </summary>
  319. [DefaultValue(DataGridViewSelectionMode.RowHeaderSelect)]
  320. [Category("Behavior")]
  321. public DataGridViewSelectionMode SelectionMode
  322. {
  323. get { return DataGridView.SelectionMode; }
  324. set { DataGridView.SelectionMode = value; }
  325. }
  326. #endregion
  327. #region Private Methods
  328. private void DataSource_Disposed(object sender, EventArgs e)
  329. {
  330. dataSource = null;
  331. }
  332. #endregion
  333. #region Protected Methods
  334. /// <inheritdoc/>
  335. protected override void DeserializeSubItems(FRReader reader)
  336. {
  337. if (String.Compare(reader.ItemName, "Columns", true) == 0)
  338. reader.Read(Columns);
  339. else
  340. base.DeserializeSubItems(reader);
  341. }
  342. #endregion
  343. #region IParent Members
  344. /// <inheritdoc/>
  345. public bool CanContain(Base child)
  346. {
  347. return child is GridControlColumn;
  348. }
  349. /// <inheritdoc/>
  350. public void GetChildObjects(ObjectCollection list)
  351. {
  352. // do nothing, prevent displaying columns in the report tree
  353. }
  354. /// <inheritdoc/>
  355. public void AddChild(Base child)
  356. {
  357. if (child is GridControlColumn)
  358. Columns.Add(child as GridControlColumn);
  359. }
  360. /// <inheritdoc/>
  361. public void RemoveChild(Base child)
  362. {
  363. if (child is GridControlColumn)
  364. Columns.Remove(child as GridControlColumn);
  365. }
  366. /// <inheritdoc/>
  367. public int GetChildOrder(Base child)
  368. {
  369. return 0;
  370. }
  371. /// <inheritdoc/>
  372. public void SetChildOrder(Base child, int order)
  373. {
  374. // do nothing
  375. }
  376. /// <inheritdoc/>
  377. public void UpdateLayout(float dx, float dy)
  378. {
  379. // do nothing
  380. }
  381. #endregion
  382. #region Public Methods
  383. internal static void WriteCellStyle(FRWriter writer, string prefix,
  384. DataGridViewCellStyle style, DataGridViewCellStyle diff)
  385. {
  386. if (style.Alignment != diff.Alignment)
  387. writer.WriteValue(prefix + ".Alignment", style.Alignment);
  388. if (style.BackColor != diff.BackColor)
  389. writer.WriteValue(prefix + ".BackColor", style.BackColor);
  390. if (style.Font != null && ((writer.SerializeTo != SerializeTo.Preview || !style.Font.Equals(diff.Font))) && writer.ItemName != "inherited")
  391. writer.WriteValue(prefix + ".Font", style.Font);
  392. if (style.ForeColor != diff.ForeColor)
  393. writer.WriteValue(prefix + ".ForeColor", style.ForeColor);
  394. if (style.Format != diff.Format)
  395. writer.WriteStr(prefix + ".Format", style.Format);
  396. if (style.NullValue != diff.NullValue)
  397. writer.WriteStr(prefix + ".NullValue", style.NullValue == null ? "" : style.NullValue.ToString());
  398. if (style.Padding != diff.Padding)
  399. writer.WriteValue(prefix + ".Padding", style.Padding);
  400. if (style.SelectionBackColor != diff.SelectionBackColor)
  401. writer.WriteValue(prefix + ".SelectionBackColor", style.SelectionBackColor);
  402. if (style.SelectionForeColor != diff.SelectionForeColor)
  403. writer.WriteValue(prefix + ".SelectionForeColor", style.SelectionForeColor);
  404. if (style.WrapMode != diff.WrapMode)
  405. writer.WriteValue(prefix + ".WrapMode", style.WrapMode);
  406. }
  407. /// <inheritdoc/>
  408. public override void Serialize(FRWriter writer)
  409. {
  410. GridControl c = writer.DiffObject as GridControl;
  411. base.Serialize(writer);
  412. if (DataSource != c.DataSource)
  413. writer.WriteRef("DataSource", DataSource);
  414. if (AllowUserToAddRows != c.AllowUserToAddRows)
  415. writer.WriteBool("AllowUserToAddRows", AllowUserToAddRows);
  416. if (AllowUserToDeleteRows != c.AllowUserToDeleteRows)
  417. writer.WriteBool("AllowUserToDeleteRows", AllowUserToDeleteRows);
  418. WriteCellStyle(writer, "AlternatingRowsDefaultCellStyle",
  419. AlternatingRowsDefaultCellStyle, c.AlternatingRowsDefaultCellStyle);
  420. if (AutoSizeColumnsMode != c.AutoSizeColumnsMode)
  421. writer.WriteValue("AutoSizeColumnsMode", AutoSizeColumnsMode);
  422. if (AutoSizeRowsMode != c.AutoSizeRowsMode)
  423. writer.WriteValue("AutoSizeRowsMode", AutoSizeRowsMode);
  424. if (BackgroundColor != c.BackgroundColor)
  425. writer.WriteValue("BackgroundColor", BackgroundColor);
  426. if (BorderStyle != c.BorderStyle)
  427. writer.WriteValue("BorderStyle", BorderStyle);
  428. if (CellBorderStyle != c.CellBorderStyle)
  429. writer.WriteValue("CellBorderStyle", CellBorderStyle);
  430. if (ColumnHeadersBorderStyle != c.ColumnHeadersBorderStyle)
  431. writer.WriteValue("ColumnHeadersBorderStyle", ColumnHeadersBorderStyle);
  432. WriteCellStyle(writer, "ColumnHeadersDefaultCellStyle",
  433. ColumnHeadersDefaultCellStyle, c.ColumnHeadersDefaultCellStyle);
  434. if (ColumnHeadersHeight != c.ColumnHeadersHeight)
  435. writer.WriteInt("ColumnHeadersHeight", ColumnHeadersHeight);
  436. if (ColumnHeadersHeightSizeMode != c.ColumnHeadersHeightSizeMode)
  437. writer.WriteValue("ColumnHeadersHeightSizeMode", ColumnHeadersHeightSizeMode);
  438. if (ColumnHeadersVisible != c.ColumnHeadersVisible)
  439. writer.WriteBool("ColumnHeadersVisible", ColumnHeadersVisible);
  440. WriteCellStyle(writer, "DefaultCellStyle",
  441. DefaultCellStyle, c.DefaultCellStyle);
  442. if (GridColor != c.GridColor)
  443. writer.WriteValue("GridColor", GridColor);
  444. if (MultiSelect != c.MultiSelect)
  445. writer.WriteBool("MultiSelect", MultiSelect);
  446. if (ReadOnly != c.ReadOnly)
  447. writer.WriteBool("ReadOnly", ReadOnly);
  448. if (RowHeadersBorderStyle != c.RowHeadersBorderStyle)
  449. writer.WriteValue("RowHeadersBorderStyle", RowHeadersBorderStyle);
  450. WriteCellStyle(writer, "RowHeadersDefaultCellStyle",
  451. RowHeadersDefaultCellStyle, c.RowHeadersDefaultCellStyle);
  452. if (RowHeadersVisible != c.RowHeadersVisible)
  453. writer.WriteBool("RowHeadersVisible", RowHeadersVisible);
  454. if (RowHeadersWidth != c.RowHeadersWidth)
  455. writer.WriteInt("RowHeadersWidth", RowHeadersWidth);
  456. if (RowHeadersWidthSizeMode != c.RowHeadersWidthSizeMode)
  457. writer.WriteValue("RowHeadersWidthSizeMode", RowHeadersWidthSizeMode);
  458. WriteCellStyle(writer, "RowsDefaultCellStyle",
  459. RowsDefaultCellStyle, c.RowsDefaultCellStyle);
  460. if (ScrollBars != c.ScrollBars)
  461. writer.WriteValue("ScrollBars", ScrollBars);
  462. if (SelectionMode != c.SelectionMode)
  463. writer.WriteValue("SelectionMode", SelectionMode);
  464. if (Columns.Count > 0)
  465. writer.Write(Columns);
  466. }
  467. /// <inheritdoc/>
  468. public override void Clear()
  469. {
  470. base.Clear();
  471. Columns.Clear();
  472. }
  473. /// <inheritdoc/>
  474. public override void InitializeControl()
  475. {
  476. base.InitializeControl();
  477. foreach (GridControlColumn column in Columns)
  478. {
  479. column.InitColumn();
  480. }
  481. if (DataSource != null)
  482. {
  483. DataSource.Init();
  484. if (DataSource is TableDataSource)
  485. DataGridView.DataSource = (DataSource as TableDataSource).Table;
  486. else
  487. DataGridView.DataSource = DataSource.Rows;
  488. }
  489. }
  490. /// <inheritdoc/>
  491. public override void FinalizeControl()
  492. {
  493. base.FinalizeControl();
  494. DataGridView.DataSource = null;
  495. }
  496. #endregion
  497. /// <summary>
  498. /// Initializes a new instance of the <b>GridControl</b> class with default settings.
  499. /// </summary>
  500. public GridControl()
  501. {
  502. dataGridView = new DataGridView();
  503. Control = dataGridView;
  504. columns = new GridControlColumnCollection(this);
  505. DataGridView.AutoGenerateColumns = false;
  506. DataGridView.AllowUserToAddRows = false;
  507. DataGridView.AllowUserToDeleteRows = false;
  508. DataGridView.ReadOnly = true;
  509. DataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.WhiteSmoke;
  510. }
  511. }
  512. }