CheckBoxCellRenderer.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. //#########################################################################################
  2. //★★★★★★★ http://www.cnpopsoft.com [华普软件] ★★★★★★★
  3. //★★★★★★★ 华普软件 - VB & C#.NET 专业论文与源码荟萃! ★★★★★★★
  4. //#########################################################################################
  5. /*
  6. * Copyright ?2005, Mathew Hall
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modification,
  10. * are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  25. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  28. * OF SUCH DAMAGE.
  29. */
  30. using System;
  31. using System.ComponentModel;
  32. using System.Drawing;
  33. using System.Globalization;
  34. using System.Windows.Forms;
  35. using XPTable.Events;
  36. using XPTable.Models;
  37. using XPTable.Themes;
  38. namespace XPTable.Renderers
  39. {
  40. /// <summary>
  41. /// A CellRenderer that draws Cell contents as CheckBoxes
  42. /// </summary>
  43. public class CheckBoxCellRenderer : CellRenderer
  44. {
  45. #region Class Data
  46. /// <summary>
  47. /// The size of the checkbox
  48. /// </summary>
  49. private Size checkSize;
  50. /// <summary>
  51. /// Specifies whether any text contained in the Cell should be drawn
  52. /// </summary>
  53. private bool drawText;
  54. #endregion
  55. #region Constructor
  56. /// <summary>
  57. /// Initializes a new instance of the CheckBoxCellRenderer class with
  58. /// default settings
  59. /// </summary>
  60. public CheckBoxCellRenderer() : base()
  61. {
  62. this.checkSize = new Size(13, 13);
  63. this.drawText = true;
  64. }
  65. #endregion
  66. #region Methods
  67. /// <summary>
  68. /// Gets the Rectangle that specifies the Size and Location of
  69. /// the check box contained in the current Cell
  70. /// </summary>
  71. /// <returns>A Rectangle that specifies the Size and Location of
  72. /// the check box contained in the current Cell</returns>
  73. protected Rectangle CalcCheckRect(RowAlignment rowAlignment, ColumnAlignment columnAlignment)
  74. {
  75. Rectangle checkRect = new Rectangle(this.ClientRectangle.Location, this.CheckSize);
  76. if (checkRect.Height > this.ClientRectangle.Height)
  77. {
  78. checkRect.Height = this.ClientRectangle.Height;
  79. checkRect.Width = checkRect.Height;
  80. }
  81. switch (rowAlignment)
  82. {
  83. case RowAlignment.Center:
  84. {
  85. checkRect.Y += (this.ClientRectangle.Height - checkRect.Height) / 2;
  86. break;
  87. }
  88. case RowAlignment.Bottom:
  89. {
  90. checkRect.Y = this.ClientRectangle.Bottom - checkRect.Height;
  91. break;
  92. }
  93. }
  94. if (!this.DrawText)
  95. {
  96. if (columnAlignment == ColumnAlignment.Center)
  97. {
  98. checkRect.X += (this.ClientRectangle.Width - checkRect.Width) / 2;
  99. }
  100. else if (columnAlignment == ColumnAlignment.Right)
  101. {
  102. checkRect.X = this.ClientRectangle.Right - checkRect.Width;
  103. }
  104. }
  105. return checkRect;
  106. }
  107. /// <summary>
  108. /// Gets the CheckBoxCellRenderer specific data used by the Renderer from
  109. /// the specified Cell
  110. /// </summary>
  111. /// <param name="cell">The Cell to get the CheckBoxCellRenderer data for</param>
  112. /// <returns>The CheckBoxCellRenderer data for the specified Cell</returns>
  113. protected CheckBoxRendererData GetCheckBoxRendererData(Cell cell)
  114. {
  115. object rendererData = this.GetRendererData(cell);
  116. if (rendererData == null || !(rendererData is CheckBoxRendererData))
  117. {
  118. if (cell.CheckState == CheckState.Unchecked)
  119. {
  120. rendererData = new CheckBoxRendererData(CheckBoxStates.UncheckedNormal);
  121. }
  122. else if (cell.CheckState == CheckState.Indeterminate && cell.ThreeState)
  123. {
  124. rendererData = new CheckBoxRendererData(CheckBoxStates.MixedNormal);
  125. }
  126. else
  127. {
  128. rendererData = new CheckBoxRendererData(CheckBoxStates.CheckedNormal);
  129. }
  130. this.SetRendererData(cell, rendererData);
  131. }
  132. this.ValidateCheckState(cell, (CheckBoxRendererData) rendererData);
  133. return (CheckBoxRendererData) rendererData;
  134. }
  135. /// <summary>
  136. /// Corrects any differences between the check state of the specified Cell
  137. /// and the check state in its rendererData
  138. /// </summary>
  139. /// <param name="cell">The Cell to chech</param>
  140. /// <param name="rendererData">The CheckBoxRendererData to check</param>
  141. private void ValidateCheckState(Cell cell, CheckBoxRendererData rendererData)
  142. {
  143. switch (cell.CheckState)
  144. {
  145. case CheckState.Checked:
  146. {
  147. if (rendererData.CheckState <= CheckBoxStates.UncheckedDisabled)
  148. {
  149. rendererData.CheckState |= (CheckBoxStates) 4;
  150. }
  151. else if (rendererData.CheckState >= CheckBoxStates.MixedNormal)
  152. {
  153. rendererData.CheckState -= (CheckBoxStates) 4;
  154. }
  155. break;
  156. }
  157. case CheckState.Indeterminate:
  158. {
  159. if (rendererData.CheckState <= CheckBoxStates.UncheckedDisabled)
  160. {
  161. rendererData.CheckState |= (CheckBoxStates) 8;
  162. }
  163. else if (rendererData.CheckState <= CheckBoxStates.CheckedDisabled)
  164. {
  165. rendererData.CheckState |= (CheckBoxStates) 4;
  166. }
  167. break;
  168. }
  169. default:
  170. {
  171. if (rendererData.CheckState >= CheckBoxStates.MixedNormal)
  172. {
  173. rendererData.CheckState -= (CheckBoxStates) 8;
  174. }
  175. else if (rendererData.CheckState >= CheckBoxStates.CheckedNormal)
  176. {
  177. rendererData.CheckState -= (CheckBoxStates) 4;
  178. }
  179. break;
  180. }
  181. }
  182. }
  183. #endregion
  184. #region Properties
  185. /// <summary>
  186. /// Gets the size of the checkbox
  187. /// </summary>
  188. protected Size CheckSize
  189. {
  190. get
  191. {
  192. return this.checkSize;
  193. }
  194. }
  195. /// <summary>
  196. /// Gets or sets whether any text contained in the Cell should be drawn
  197. /// </summary>
  198. public bool DrawText
  199. {
  200. get
  201. {
  202. return this.drawText;
  203. }
  204. }
  205. #endregion
  206. #region Events
  207. #region Keys
  208. /// <summary>
  209. /// Raises the KeyDown event
  210. /// </summary>
  211. /// <param name="e">A CellKeyEventArgs that contains the event data</param>
  212. public override void OnKeyDown(CellKeyEventArgs e)
  213. {
  214. base.OnKeyDown(e);
  215. if (e.KeyData == Keys.Space && e.Table.IsCellEditable(e.CellPos))
  216. {
  217. // get the renderer data
  218. CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);
  219. //
  220. if (e.Cell.CheckState == CheckState.Checked)
  221. {
  222. rendererData.CheckState = CheckBoxStates.CheckedPressed;
  223. }
  224. else if (e.Cell.CheckState == CheckState.Indeterminate)
  225. {
  226. rendererData.CheckState = CheckBoxStates.MixedPressed;
  227. }
  228. else //if (e.Cell.CheckState == CheckState.Unchecked)
  229. {
  230. rendererData.CheckState = CheckBoxStates.UncheckedPressed;
  231. }
  232. e.Table.Invalidate(e.CellRect);
  233. }
  234. }
  235. /// <summary>
  236. /// Raises the KeyUp event
  237. /// </summary>
  238. /// <param name="e">A CellKeyEventArgs that contains the event data</param>
  239. public override void OnKeyUp(CellKeyEventArgs e)
  240. {
  241. base.OnKeyUp(e);
  242. if (e.KeyData == Keys.Space && e.Table.IsCellEditable(e.CellPos))
  243. {
  244. // get the renderer data
  245. CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);
  246. //
  247. if (e.Cell.CheckState == CheckState.Checked)
  248. {
  249. if (!e.Cell.ThreeState || !(e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn) ||
  250. ((CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column]).CheckStyle == CheckBoxColumnStyle.RadioButton)
  251. {
  252. rendererData.CheckState = CheckBoxStates.UncheckedNormal;
  253. e.Cell.CheckState = CheckState.Unchecked;
  254. }
  255. else
  256. {
  257. rendererData.CheckState = CheckBoxStates.MixedNormal;
  258. e.Cell.CheckState = CheckState.Indeterminate;
  259. }
  260. }
  261. else if (e.Cell.CheckState == CheckState.Indeterminate)
  262. {
  263. rendererData.CheckState = CheckBoxStates.UncheckedNormal;
  264. e.Cell.CheckState = CheckState.Unchecked;
  265. }
  266. else //if (e.Cell.CheckState == CheckState.Unchecked)
  267. {
  268. rendererData.CheckState = CheckBoxStates.CheckedNormal;
  269. e.Cell.CheckState = CheckState.Checked;
  270. }
  271. e.Table.Invalidate(e.CellRect);
  272. }
  273. }
  274. #endregion
  275. #region Mouse
  276. #region MouseLeave
  277. /// <summary>
  278. /// Raises the MouseLeave event
  279. /// </summary>
  280. /// <param name="e">A CellMouseEventArgs that contains the event data</param>
  281. public override void OnMouseLeave(CellMouseEventArgs e)
  282. {
  283. base.OnMouseLeave(e);
  284. if (e.Table.IsCellEditable(e.CellPos))
  285. {
  286. // get the renderer data
  287. CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);
  288. if (e.Cell.CheckState == CheckState.Checked)
  289. {
  290. if (rendererData.CheckState != CheckBoxStates.CheckedNormal)
  291. {
  292. rendererData.CheckState = CheckBoxStates.CheckedNormal;
  293. e.Table.Invalidate(e.CellRect);
  294. }
  295. }
  296. else if (e.Cell.CheckState == CheckState.Indeterminate)
  297. {
  298. if (rendererData.CheckState != CheckBoxStates.MixedNormal)
  299. {
  300. rendererData.CheckState = CheckBoxStates.MixedNormal;
  301. e.Table.Invalidate(e.CellRect);
  302. }
  303. }
  304. else //if (e.Cell.CheckState == CheckState.Unchecked)
  305. {
  306. if (rendererData.CheckState != CheckBoxStates.UncheckedNormal)
  307. {
  308. rendererData.CheckState = CheckBoxStates.UncheckedNormal;
  309. e.Table.Invalidate(e.CellRect);
  310. }
  311. }
  312. }
  313. }
  314. #endregion
  315. #region MouseUp
  316. /// <summary>
  317. /// Raises the MouseUp event
  318. /// </summary>
  319. /// <param name="e">A CellMouseEventArgs that contains the event data</param>
  320. public override void OnMouseUp(CellMouseEventArgs e)
  321. {
  322. base.OnMouseUp(e);
  323. if (e.Table.IsCellEditable(e.CellPos))
  324. {
  325. // get the renderer data
  326. CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);
  327. if (this.CalcCheckRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].Alignment).Contains(e.X, e.Y))
  328. {
  329. if (e.Button == MouseButtons.Left && e.Table.LastMouseDownCell.Row == e.Row && e.Table.LastMouseDownCell.Column == e.Column)
  330. {
  331. //
  332. if (e.Cell.CheckState == CheckState.Checked)
  333. {
  334. if (!e.Cell.ThreeState || !(e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn) ||
  335. ((CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column]).CheckStyle == CheckBoxColumnStyle.RadioButton)
  336. {
  337. rendererData.CheckState = CheckBoxStates.UncheckedHot;
  338. e.Cell.CheckState = CheckState.Unchecked;
  339. }
  340. else
  341. {
  342. rendererData.CheckState = CheckBoxStates.MixedHot;
  343. e.Cell.CheckState = CheckState.Indeterminate;
  344. }
  345. }
  346. else if (e.Cell.CheckState == CheckState.Indeterminate)
  347. {
  348. rendererData.CheckState = CheckBoxStates.UncheckedHot;
  349. e.Cell.CheckState = CheckState.Unchecked;
  350. }
  351. else //if (e.Cell.CheckState == CheckState.Unchecked)
  352. {
  353. rendererData.CheckState = CheckBoxStates.CheckedHot;
  354. e.Cell.CheckState = CheckState.Checked;
  355. }
  356. e.Table.Invalidate(e.CellRect);
  357. }
  358. }
  359. }
  360. }
  361. #endregion
  362. #region MouseDown
  363. /// <summary>
  364. /// Raises the MouseDown event
  365. /// </summary>
  366. /// <param name="e">A CellMouseEventArgs that contains the event data</param>
  367. public override void OnMouseDown(CellMouseEventArgs e)
  368. {
  369. base.OnMouseDown(e);
  370. if (e.Table.IsCellEditable(e.CellPos))
  371. {
  372. // get the renderer data
  373. CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);
  374. if (this.CalcCheckRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].Alignment).Contains(e.X, e.Y))
  375. {
  376. //
  377. if (e.Cell.CheckState == CheckState.Checked)
  378. {
  379. rendererData.CheckState = CheckBoxStates.CheckedPressed;
  380. }
  381. else if (e.Cell.CheckState == CheckState.Indeterminate)
  382. {
  383. rendererData.CheckState = CheckBoxStates.MixedPressed;
  384. }
  385. else //if (e.Cell.CheckState == CheckState.Unchecked)
  386. {
  387. rendererData.CheckState = CheckBoxStates.UncheckedPressed;
  388. }
  389. e.Table.Invalidate(e.CellRect);
  390. }
  391. }
  392. }
  393. #endregion
  394. #region MouseMove
  395. /// <summary>
  396. /// Raises the MouseMove event
  397. /// </summary>
  398. /// <param name="e">A CellMouseEventArgs that contains the event data</param>
  399. public override void OnMouseMove(XPTable.Events.CellMouseEventArgs e)
  400. {
  401. base.OnMouseMove(e);
  402. if (e.Table.IsCellEditable(e.CellPos))
  403. {
  404. // get the renderer data
  405. CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);
  406. if (this.CalcCheckRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].Alignment).Contains(e.X, e.Y))
  407. {
  408. if (e.Cell.CheckState == CheckState.Checked)
  409. {
  410. if (rendererData.CheckState == CheckBoxStates.CheckedNormal)
  411. {
  412. if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
  413. {
  414. rendererData.CheckState = CheckBoxStates.CheckedPressed;
  415. }
  416. else
  417. {
  418. rendererData.CheckState = CheckBoxStates.CheckedHot;
  419. }
  420. e.Table.Invalidate(e.CellRect);
  421. }
  422. }
  423. else if (e.Cell.CheckState == CheckState.Indeterminate)
  424. {
  425. if (rendererData.CheckState == CheckBoxStates.MixedNormal)
  426. {
  427. if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
  428. {
  429. rendererData.CheckState = CheckBoxStates.MixedPressed;
  430. }
  431. else
  432. {
  433. rendererData.CheckState = CheckBoxStates.MixedHot;
  434. }
  435. e.Table.Invalidate(e.CellRect);
  436. }
  437. }
  438. else //if (e.Cell.CheckState == CheckState.Unchecked)
  439. {
  440. if (rendererData.CheckState == CheckBoxStates.UncheckedNormal)
  441. {
  442. if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
  443. {
  444. rendererData.CheckState = CheckBoxStates.UncheckedPressed;
  445. }
  446. else
  447. {
  448. rendererData.CheckState = CheckBoxStates.UncheckedHot;
  449. }
  450. e.Table.Invalidate(e.CellRect);
  451. }
  452. }
  453. }
  454. else
  455. {
  456. if (e.Cell.CheckState == CheckState.Checked)
  457. {
  458. rendererData.CheckState = CheckBoxStates.CheckedNormal;
  459. }
  460. else if (e.Cell.CheckState == CheckState.Indeterminate)
  461. {
  462. rendererData.CheckState = CheckBoxStates.MixedNormal;
  463. }
  464. else //if (e.Cell.CheckState == CheckState.Unchecked)
  465. {
  466. rendererData.CheckState = CheckBoxStates.UncheckedNormal;
  467. }
  468. e.Table.Invalidate(e.CellRect);
  469. }
  470. }
  471. }
  472. #endregion
  473. #endregion
  474. #region Paint
  475. /// <summary>
  476. /// Raises the PaintCell event
  477. /// </summary>
  478. /// <param name="e">A PaintCellEventArgs that contains the event data</param>
  479. public override void OnPaintCell(PaintCellEventArgs e)
  480. {
  481. if (e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn)
  482. {
  483. CheckBoxColumn column = (CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column];
  484. this.checkSize = column.CheckSize;
  485. this.drawText = column.DrawText;
  486. }
  487. else
  488. {
  489. this.checkSize = new Size(13, 13);
  490. this.drawText = true;
  491. }
  492. base.OnPaintCell(e);
  493. }
  494. /// <summary>
  495. /// Raises the Paint event
  496. /// </summary>
  497. /// <param name="e">A PaintCellEventArgs that contains the event data</param>
  498. protected override void OnPaint(PaintCellEventArgs e)
  499. {
  500. base.OnPaint(e);
  501. // don't bother if the Cell is null
  502. if (e.Cell == null)
  503. {
  504. return;
  505. }
  506. Rectangle checkRect = this.CalcCheckRect(this.LineAlignment, this.Alignment);
  507. CheckBoxStates state = this.GetCheckBoxRendererData(e.Cell).CheckState;
  508. if (!e.Enabled)
  509. {
  510. if (e.Cell.CheckState == CheckState.Checked)
  511. {
  512. state = CheckBoxStates.CheckedDisabled;
  513. }
  514. else if (e.Cell.CheckState == CheckState.Indeterminate)
  515. {
  516. state = CheckBoxStates.MixedDisabled;
  517. }
  518. else // if (e.Cell.CheckState == CheckState.Unchecked)
  519. {
  520. state = CheckBoxStates.UncheckedDisabled;
  521. }
  522. }
  523. if (e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn &&
  524. ((CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column]).CheckStyle != CheckBoxColumnStyle.CheckBox)
  525. {
  526. // remove any mixed states
  527. switch (state)
  528. {
  529. case CheckBoxStates.MixedNormal:
  530. state = CheckBoxStates.CheckedNormal;
  531. break;
  532. case CheckBoxStates.MixedHot:
  533. state = CheckBoxStates.CheckedHot;
  534. break;
  535. case CheckBoxStates.MixedPressed:
  536. state = CheckBoxStates.CheckedPressed;
  537. break;
  538. case CheckBoxStates.MixedDisabled:
  539. state = CheckBoxStates.CheckedDisabled;
  540. break;
  541. }
  542. ThemeManager.DrawRadioButton(e.Graphics, checkRect, (RadioButtonStates) state);
  543. }
  544. else
  545. {
  546. ThemeManager.DrawCheck(e.Graphics, checkRect, state);
  547. }
  548. if (this.DrawText)
  549. {
  550. string text = e.Cell.Text;
  551. if (text != null && text.Length != 0)
  552. {
  553. Rectangle textRect = this.ClientRectangle;
  554. textRect.X += checkRect.Width + 1;
  555. textRect.Width -= checkRect.Width + 1;
  556. if (e.Enabled)
  557. {
  558. e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
  559. }
  560. else
  561. {
  562. e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat);
  563. }
  564. }
  565. }
  566. if (e.Focused && e.Enabled)
  567. {
  568. ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
  569. }
  570. }
  571. #endregion
  572. #endregion
  573. }
  574. }