功能:

一.列相关:

1.追加列,左插列,右插列,

2.删除列

二.行相关:

1.追加行,上插行,下插行

2.删除行,删除所有空行,清空所有数据...

原理:根据对鼠标于 DataGridView 点击区域的判断来 对 点击列 或 点击行 的准确定位,再执行操作...

优点:

1.只需要 CellMouseDown 事件所输出的 DataGridViewCellMouseEventArgs 参数来判断,便可取代 通常情况下对行列操作函数所需要输入的 点击列 或 点击行...
2.具有行列相关操作 某些方面 一定的综合性;

缺点:
1.由于其在某些操作方面的综合性,相比专一针对某个列或某行进行操作的函数肯定稍慢..

注明:

1.所提供的函数可能还没有达到所有情况下的测试,但目前本人还没发现出错的地方...

2.新增列操作函数中有可以改进的地方...[相关代码段有注明]

以下是相关代码:

  1. public static partial class Dgv
  2. {
  3. #region 点击行列 基本信息 获取
  4.  
  5. /// <summary>
  6. /// 根据鼠标点击的单元格信息,输出 单元格 的作用分类作用区域
  7. /// 注:由于 dgv 的列名行/行标头 都是有不同分工作用的单元格 Cell 组成,所以,以下判断均为判断 点击的 Cell 所在的 行索引与列索引来判断 所属的分类作用区域
  8. /// 时间: 2021/07/02 20:00:58
  9. /// </summary>
  10. /// <param name="e"></param>
  11. /// <returns></returns>
  12. public static EAra _CellMouseDown(object s, DataGridViewCellMouseEventArgs e, out DataGridViewColumn clkDgvC, out DataGridViewRow clkDgvR, out DataGridViewCell clkDgvc)
  13. {
  14. DataGridView dgv = s as DataGridView;
  15. return _CellMouseDown(dgv, e, out clkDgvC, out clkDgvR, out clkDgvc);
  16. }
  17. /// <summary>
  18. /// 根据鼠标点击的单元格信息,输出 单元格 的作用分类作用区域
  19. /// 注:由于 dgv 的列名行/行标头 都是有不同分工作用的单元格 Cell 组成,所以,以下判断均为判断 点击的 Cell 所在的 行索引与列索引来判断 所属的分类作用区域
  20. /// 时间: 2021/07/02 20:00:58
  21. /// </summary>
  22. /// <param name="e"></param>
  23. /// <returns></returns>
  24. public static EAra _CellMouseDown(DataGridView dgv, DataGridViewCellMouseEventArgs e, out DataGridViewColumn clkDgvC, out DataGridViewRow clkDgvR, out DataGridViewCell clkDgvc)
  25. {
  26. #region
  27.  
  28. clkDgvC = null;
  29. clkDgvR = null;
  30. clkDgvc = null;
  31. EAra eAra = EAra.non;
  32.  
  33. if (e == null)
  34. eAra = EAra.all;
  35. else
  36. {
  37. #region
  38.  
  39. int iRow = e.RowIndex;
  40. int iCol = e.ColumnIndex;
  41.  
  42. if (iRow < 0)
  43. {
  44. #region
  45.  
  46. if (iCol < 0)
  47. eAra = EAra.all;
  48. else
  49. {
  50. eAra = EAra.col;
  51. clkDgvC = dgv.Columns[iCol];
  52. }
  53.  
  54. #endregion
  55. }
  56. else if (iCol < 0)
  57. {
  58. eAra = EAra.row;
  59. clkDgvR = dgv.Rows[iRow];//.CurrentRow;
  60. }
  61. else
  62. {
  63. eAra = EAra.cel;
  64. clkDgvc = dgv.Rows[iRow].Cells[iCol];//.CurrentCell;
  65. }
  66.  
  67. #endregion
  68. }
  69. return eAra;
  70.  
  71. #endregion
  72. }
  73. /// <summary>
  74. /// 根据鼠标点击的单元格信息,输出 单元格 的作用分类作用区域
  75. /// 注:由于 dgv 的列名行/行标头 都是有不同分工作用的单元格 Cell 组成,所以,以下判断均为判断 点击的 Cell 所在的 行索引与列索引来判断 所属的分类作用区域
  76. /// 时间: 2021/07/02 20:00:58
  77. /// </summary>
  78. /// <param name="e"></param>
  79. /// <returns></returns>
  80. public static EAra _CellMouseDown(DataGridViewCellMouseEventArgs e)
  81. {
  82. #region
  83.  
  84. EAra eAra = EAra.non;
  85. if (e == null)
  86. eAra = EAra.all;
  87. else
  88. {
  89. #region
  90.  
  91. int iRow = e.RowIndex;
  92. int iCol = e.ColumnIndex;
  93.  
  94. if (iRow < 0)
  95. {
  96. #region
  97.  
  98. if (iCol < 0)
  99. eAra = EAra.all;
  100. else
  101. eAra = EAra.col;
  102.  
  103. #endregion
  104. }
  105. else if (iCol < 0)
  106. eAra = EAra.row;
  107. else
  108. eAra = EAra.cel;
  109.  
  110. #endregion
  111. }
  112.  
  113. return eAra;
  114.  
  115. #endregion
  116. }
  117. /// <summary>
  118. /// 根据 _CellMouseDown 判断点击的区域, 获取可能与点击操作相关的列 [如:点击单元格对应的列,直击列名列,反之为 null ]
  119. /// 时间: 2021/07/02 20:00:58
  120. /// </summary>
  121. /// <param name="dgv"></param>
  122. /// <param name="e"></param>
  123. /// <param name="clkDgvC"></param>
  124. public static void ClkDgvC(DataGridView dgv, DataGridViewCellMouseEventArgs e, out DataGridViewColumn clkDgvC)
  125. {
  126. #region
  127.  
  128. clkDgvC = null;
  129. DataGridViewRow clkDgvR = null;
  130. DataGridViewCell clkDgvc = null;
  131.  
  132. EAra eAra = _CellMouseDown(dgv, e, out clkDgvC, out clkDgvR, out clkDgvc);
  133. if (eAra == EAra.all || eAra == EAra.non)
  134. return;
  135.  
  136. if (clkDgvR != null)
  137. return;
  138.  
  139. if (clkDgvC == null)
  140. {
  141. if (clkDgvc == null)
  142. return;
  143.  
  144. clkDgvC = clkDgvc.OwningColumn;
  145. }
  146.  
  147. #endregion
  148. }
  149.  
  150. #endregion
  151.  
  152. /// <summary>
  153. /// [综合情况] 综合处理
  154. /// 时间: 2021/07/02 23:45:58
  155. /// </summary>
  156. public static class Col2
  157. {
  158. #region
  159.  
  160. #region [综合情况] 新增列
  161.  
  162. /// <summary>
  163. /// [综合情况] 新增列
  164. /// </summary>
  165. /// <param name="dgv"></param>
  166. /// <param name="insCelTyp"></param>
  167. /// <param name="colNam"></param>
  168. /// <param name="insRit"></param>
  169. /// <param name="e"></param>
  170. public static void New(DataGridView dgv, DataGridViewCell insCelTyp, string colNam, bool insRit, ref DataGridViewCellMouseEventArgs e)
  171. {
  172. #region
  173.  
  174. #region
  175.  
  176. DataGridViewColumn clkDgvC = null;
  177. ClkDgvC(dgv, e, out clkDgvC);
  178.  
  179. int cnt = dgv.ColumnCount;
  180. cnt++;
  181. if (colNam == "")
  182. colNam = "F" + cnt;
  183.  
  184. int dspIdx = -1;
  185. if (clkDgvC == null)
  186. dspIdx = cnt;
  187. else
  188. {
  189. dspIdx = clkDgvC.DisplayIndex;
  190. if (insRit)
  191. dspIdx++;
  192. }
  193.  
  194. #endregion
  195.  
  196. #region
  197.  
  198. object obj = dgv.DataSource;
  199. if (obj == null)
  200. {
  201. #region
  202.  
  203. if (insCelTyp == null)
  204. insCelTyp = Col.ETyp.cTxt;
  205.  
  206. DataGridViewColumn dgvC = new DataGridViewColumn(insCelTyp);
  207. dgvC.SortMode = DataGridViewColumnSortMode.Automatic;
  208. dgvC.HeaderText = colNam;
  209. dgv.Columns.Add(dgvC);
  210. dgvC.DisplayIndex = dspIdx;
  211.  
  212. #endregion
  213. }
  214. else
  215. {
  216. #region
  217.  
  218. string typ = obj.GetType().Name;
  219. if (typ == EDat.DataTable + "")
  220. {
  221. #region
  222.  
  223. #region 操作 DataTable 对象
  224.  
  225. DataGridViewColumn dgvC;
  226.  
  227. #region 以下包含代码可能有别的解决方法,此不临时替代
  228.  
  229. #region 记录加列前的列的 显序
  230.  
  231. int[] dspIdxS = new int[cnt];
  232. for (int i = 0; i < cnt - 1; i++)
  233. {
  234. dgvC = dgv.Columns[i];
  235. dspIdxS[i] = dgvC.DisplayIndex;
  236. }
  237.  
  238. #endregion
  239.  
  240. #region 注:以上代码可能会自动打乱原列 显序
  241.  
  242. DataTable dt = obj as DataTable;
  243. DT.Col.Add(dt, colNam);
  244.  
  245. #endregion
  246.  
  247. #region 还原加列前的列的 显序
  248.  
  249. for (int i = 0; i < cnt - 1; i++)
  250. {
  251. dgvC = dgv.Columns[i];
  252. dgvC.DisplayIndex = dspIdxS[i];
  253. }
  254.  
  255. #endregion
  256.  
  257. #endregion
  258.  
  259. #endregion
  260.  
  261. if (clkDgvC != null)
  262. {
  263. #region
  264.  
  265. cnt--;
  266. dgvC = dgv.Columns[cnt];
  267. dgvC.SortMode = DataGridViewColumnSortMode.Automatic;
  268. dgvC.DisplayIndex = dspIdx;
  269.  
  270. #endregion
  271. }
  272.  
  273. #endregion
  274. }
  275.  
  276. #endregion
  277. }
  278.  
  279. #endregion
  280.  
  281. #endregion
  282. }
  283. /// <summary>
  284. /// [综合情况] 左插列
  285. /// </summary>
  286. /// <param name="dgv"></param>
  287. /// <param name="insCelTyp"></param>
  288. /// <param name="colNam"></param>
  289. /// <param name="e"></param>
  290. public static void Ins(DataGridView dgv, DataGridViewCell insCelTyp, string colNam, DataGridViewCellMouseEventArgs e)
  291. {
  292. New(dgv, insCelTyp, colNam, false, ref e);
  293. }
  294. /// <summary>
  295. /// [综合情况] 右插列
  296. /// </summary>
  297. /// <param name="dgv"></param>
  298. /// <param name="insCelTyp"></param>
  299. /// <param name="colNam"></param>
  300. /// <param name="e"></param>
  301. public static void Ins_(DataGridView dgv, DataGridViewCell insCelTyp, string colNam, DataGridViewCellMouseEventArgs e)
  302. {
  303. New(dgv, insCelTyp, colNam, true, ref e);
  304. }
  305.  
  306. /// <summary>
  307. /// [综合情况] 新增列
  308. /// </summary>
  309. /// <param name="dgv"></param>
  310. /// <param name="colNam"></param>
  311. /// <param name="insRit"></param>
  312. /// <param name="e"></param>
  313. public static void New(DataGridView dgv, string colNam, bool insRit,ref DataGridViewCellMouseEventArgs e)
  314. {
  315. DataGridViewCell insCelTyp = Col.ETyp.cTxt;
  316. New(dgv, insCelTyp, colNam, insRit, ref e);
  317. }
  318. /// <summary>
  319. /// [综合情况] 左插列
  320. /// </summary>
  321. /// <param name="dgv"></param>
  322. /// <param name="colNam"></param>
  323. /// <param name="insRit"></param>
  324. /// <param name="e"></param>
  325. public static void Ins(DataGridView dgv, string colNam, bool insRit, DataGridViewCellMouseEventArgs e)
  326. {
  327. New(dgv, colNam, false,ref e);
  328. }
  329. /// <summary>
  330. /// [综合情况] 右插列
  331. /// </summary>
  332. /// <param name="dgv"></param>
  333. /// <param name="colNam"></param>
  334. /// <param name="insRit"></param>
  335. /// <param name="e"></param>
  336. public static void Ins_(DataGridView dgv, string colNam, bool insRit, DataGridViewCellMouseEventArgs e)
  337. {
  338. New(dgv, colNam, true, ref e);
  339. }
  340.  
  341. #endregion
  342.  
  343. #region [综合情况] 删除列
  344.  
  345. /// <summary>
  346. /// [综合情况] 删除列
  347. /// </summary>
  348. /// <param name="dgv"></param>
  349. /// <param name="e"></param>
  350. public static void Del(DataGridView dgv, DataGridViewCellMouseEventArgs e)
  351. {
  352. #region
  353.  
  354. DataGridViewColumn clkDgvC = null;
  355. ClkDgvC(dgv, e, out clkDgvC);
  356.  
  357. if (clkDgvC == null)
  358. return;
  359.  
  360. object obj = dgv.DataSource;
  361. if (obj == null)
  362. dgv.Columns.Remove(clkDgvC);
  363. else
  364. {
  365. string typ = obj.GetType().Name;
  366. if (typ == EDat.DataTable + "")
  367. {
  368. int colIdx = clkDgvC.Index;
  369. DataTable dt = obj as DataTable;
  370. dt.Columns.RemoveAt(colIdx);
  371. }
  372. }
  373.  
  374. #endregion
  375. }
  376.  
  377. #endregion
  378.  
  379. #endregion
  380. }
  381.  
  382. /// <summary>
  383. /// [综合情况] 综合处理
  384. /// 时间: 2021/07/02 23:45:58
  385. /// </summary>
  386. public static class Row2
  387. {
  388. #region
  389.  
  390. #region [综合情况] 新增行
  391.  
  392. /// <summary>
  393. /// [综合情况] 新增行
  394. /// </summary>
  395. /// <param name="dgv"></param>
  396. /// <param name="insDwn"></param>
  397. /// <param name="e"></param>
  398. public static void New(DataGridView dgv, bool insDwn, ref DataGridViewCellMouseEventArgs e)
  399. {
  400. #region
  401.  
  402. #region
  403.  
  404. DataGridViewColumn clkDgvC;
  405. DataGridViewRow clkDgvR;
  406. DataGridViewCell clkDgvc;
  407. _CellMouseDown(dgv, e, out clkDgvC, out clkDgvR, out clkDgvc);
  408.  
  409. #endregion
  410.  
  411. #region
  412.  
  413. int row = dgv.Rows.Count;
  414. bool bol = dgv.AllowUserToAddRows;
  415. if (bol)
  416. row--;
  417.  
  418. int insIdx = -1;
  419. if (clkDgvR == null)
  420. insIdx = row;// --row;
  421. else
  422. {
  423. insIdx = clkDgvR.Index;
  424. if (insDwn)
  425. insIdx++;
  426. else
  427. {
  428. #region 此码作用于 能在 点击行处 连续 添加
  429.  
  430. MouseEventArgs mse = new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0);
  431. e = new DataGridViewCellMouseEventArgs(e.ColumnIndex, insIdx + 1, e.Location.X, e.Location.Y, mse);
  432.  
  433. #endregion
  434. }
  435. }
  436.  
  437. #endregion
  438.  
  439. #region
  440.  
  441. object obj = dgv.DataSource;
  442. if (obj == null)
  443. {
  444. #region
  445.  
  446. if (insIdx < row)
  447. dgv.Rows.Insert(insIdx, 1);
  448. else
  449. dgv.Rows.Add();
  450.  
  451. #endregion
  452. }
  453. else
  454. {
  455. #region
  456.  
  457. string typ = obj.GetType().Name;
  458. if (typ == EDat.DataTable + "")
  459. {
  460. #region
  461.  
  462. DataTable dt = obj as DataTable;
  463. if (insIdx < row)
  464. {
  465. DataRow dr = dt.NewRow();
  466. dt.Rows.InsertAt(dr, insIdx);
  467. }
  468. else
  469. dt.Rows.Add();
  470.  
  471. #endregion
  472. }
  473.  
  474. #endregion
  475. }
  476.  
  477. #endregion
  478.  
  479. #endregion
  480. }
  481. /// <summary>
  482. /// [综合情况] 在当前行处插入新行
  483. /// </summary>
  484. /// <param name="dgv"></param>
  485. /// <param name="e"></param>
  486. public static void Ins(DataGridView dgv, ref DataGridViewCellMouseEventArgs e)
  487. {
  488. New(dgv, false,ref e);
  489. }
  490. /// <summary>
  491. /// [综合情况] 在当前行下面插入新行
  492. /// </summary>
  493. /// <param name="dgv"></param>
  494. /// <param name="e"></param>
  495. public static void Ins_(DataGridView dgv,ref DataGridViewCellMouseEventArgs e)
  496. {
  497. New(dgv, true,ref e);
  498. }
  499.  
  500. #endregion
  501.  
  502. #region [综合情况] 删除行
  503.  
  504. public static void Del(DataGridView dgv,ref DataGridViewCellMouseEventArgs e)
  505. {
  506. #region
  507.  
  508. #region
  509.  
  510. DataGridViewColumn clkDgvC;
  511. DataGridViewRow clkDgvR;
  512. DataGridViewCell clkDgvc;
  513. _CellMouseDown(dgv, e, out clkDgvC, out clkDgvR, out clkDgvc);
  514.  
  515. if (clkDgvR == null)
  516. return;
  517.  
  518. #endregion
  519.  
  520. #region
  521.  
  522. int rowIdx = clkDgvR.Index;
  523. bool bol = dgv.AllowUserToAddRows;
  524. int cnt = dgv.Rows.Count;
  525. if (bol)
  526. {
  527. cnt--;
  528. if (rowIdx == cnt)
  529. return;
  530. }
  531.  
  532. #endregion
  533.  
  534. #region
  535.  
  536. object obj = dgv.DataSource;
  537. if (obj == null)
  538. dgv.Rows.RemoveAt(rowIdx);
  539. else
  540. {
  541. #region
  542.  
  543. string typ = obj.GetType().Name;
  544. if (typ == EDat.DataTable + "")
  545. {
  546. DataTable dt = obj as DataTable;
  547. dt.Rows.RemoveAt(rowIdx);
  548. }
  549.  
  550. #endregion
  551. }
  552.  
  553. cnt--;
  554. if (cnt < 1)
  555. {
  556. MouseEventArgs mse = new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0);
  557. e = new DataGridViewCellMouseEventArgs(e.ColumnIndex, -1, e.Location.X, e.Location.Y, mse);
  558. }
  559.  
  560. #endregion
  561.  
  562. #endregion
  563. }
  564.  
  565. #endregion
  566.  
  567. #region [综合情况] 删除所有空行
  568.  
  569. /// <summary>
  570. /// [综合情况] 删除所有空行
  571. /// </summary>
  572. /// <param name="dgv"></param>
  573. public static void Trm(DataGridView dgv)
  574. {
  575. #region
  576.  
  577. int row = dgv.Rows.Count;
  578. if (dgv.AllowUserToAddRows)
  579. row--;
  580.  
  581. if (row < 1)
  582. return;
  583.  
  584. row--;
  585. int j;
  586. int col = dgv.Columns.Count;
  587.  
  588. #endregion
  589.  
  590. #region
  591.  
  592. string vlu;
  593. object obj = dgv.DataSource;
  594. if(obj==null)
  595. {
  596. #region
  597.  
  598. DataGridViewRow dgvR;
  599. DataGridViewCell dgvc;
  600. for (int i = row; i > -1; i--)
  601. {
  602. dgvR = dgv.Rows[i];
  603. for (j = 0; j < col; j++)
  604. {
  605. dgvc = dgvR.Cells[j];
  606. vlu = dgvc.Value.ToString();
  607. if (vlu != "")// dgvc.Value != null)
  608. break;
  609. }
  610. if (j < col)
  611. continue;
  612.  
  613. dgvR = null;
  614. dgv.Rows.RemoveAt(i);
  615. }
  616.  
  617. #endregion
  618. }
  619. else
  620. {
  621. string typ = obj.GetType().Name;
  622. if(typ==EDat.DataTable+"")
  623. {
  624. #region
  625.  
  626. DataTable dt = obj as DataTable;
  627. DataRow dr;
  628. for (int i = row; i > -1; i--)
  629. {
  630. dr = dt.Rows[i];
  631. for (j = 0; j < col; j++)
  632. {
  633. vlu = dr[j] + "";
  634. if (vlu != "")
  635. break;
  636. }
  637. if (j < col)
  638. continue;
  639.  
  640. dr = null;
  641. dt.Rows.RemoveAt(i);
  642. }
  643.  
  644. #endregion
  645. }
  646. }
  647.  
  648. #endregion
  649. }
  650.  
  651. #endregion
  652.  
  653. #region [综合情况] 清空所有行
  654.  
  655. /// <summary>
  656. /// [综合情况] 清空所有行
  657. /// </summary>
  658. /// <param name="dgv"></param>
  659. public static void Clr(DataGridView dgv)
  660. {
  661. #region
  662.  
  663. int row = dgv.Rows.Count;
  664. if (dgv.AllowUserToAddRows)
  665. row--;
  666.  
  667. if (row < 1)
  668. return;
  669.  
  670. row--;
  671.  
  672. #endregion
  673.  
  674. #region
  675.  
  676. object obj = dgv.DataSource;
  677. if (obj == null)
  678. dgv.Rows.Clear();
  679. else
  680. {
  681. string typ = obj.GetType().Name;
  682. if (typ == EDat.DataTable + "")
  683. {
  684. #region
  685.  
  686. DataTable dt = obj as DataTable;
  687. dt.Rows.Clear();
  688.  
  689. #endregion
  690. }
  691. }
  692.  
  693. #endregion
  694. }
  695.  
  696. #endregion
  697.  
  698. #region [综合情况] 清空所有数据
  699.  
  700. /// <summary>
  701. /// [综合情况] 清空所有数据
  702. /// </summary>
  703. /// <param name="dgv"></param>
  704. public static void Nul(DataGridView dgv)
  705. {
  706. #region
  707.  
  708. int row = dgv.Rows.Count;
  709. if (dgv.AllowUserToAddRows)
  710. row--;
  711.  
  712. if (row < 1)
  713. return;
  714.  
  715. row--;
  716. int j;
  717. int col = dgv.Columns.Count;
  718.  
  719. #endregion
  720.  
  721. #region
  722.  
  723. object obj = dgv.DataSource;
  724. if (obj == null)
  725. {
  726. #region
  727.  
  728. DataGridViewRow dgvR;
  729. DataGridViewCell dgvc;
  730. for (int i = row; i > -1; i--)
  731. {
  732. dgvR = dgv.Rows[i];
  733. for (j = 0; j < col; j++)
  734. {
  735. dgvc = dgvR.Cells[j];
  736. if (dgvc.Value == null)
  737. continue;
  738.  
  739. dgvc.Value = "";
  740. }
  741. }
  742.  
  743. #endregion
  744. }
  745. else
  746. {
  747. string typ = obj.GetType().Name;
  748. if (typ == EDat.DataTable + "")
  749. {
  750. #region
  751.  
  752. DataTable dt = obj as DataTable;
  753. DataRow dr;
  754. for (int i = row; i > -1; i--)
  755. {
  756. dr = dt.Rows[i];
  757. for (j = 0; j < col; j++)
  758. {
  759. obj = dr[j];
  760. if (obj == null)
  761. continue;
  762.  
  763. dr[j] = "";
  764. }
  765. }
  766.  
  767. #endregion
  768. }
  769. }
  770.  
  771. #endregion
  772. }
  773.  
  774. #endregion
  775.  
  776. #endregion
  777. }
  778. }

交流 QQ : 2412366909@qq.com
手机号码:177-7499-4428

C# DataGridView 新增列 新增行 操作函数 - [ 自律相互分享,共促一起进步 - 社会的正常运维就这么简单,何以权,何以钱...- 张光荣2010年谈社会改正提出的正能量]的更多相关文章

  1. DataGridView控件的各种操作总结

    一.单元格内容的操作 *****// 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index ...

  2. c# WinForm开发 DataGridView控件的各种操作总结(单元格操作,属性设置)

    一.单元格内容的操作 *****// 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index ...

  3. 转:c# WinForm开发 DataGridView控件的各种操作总结(单元格操作,属性设置)

    一.单元格内容的操作 *****// 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index  ...

  4. (转)实现DataList的分页 新增列

    前几天在做网上商城,要展示商品信息(有图片,有文字),DataView虽然可以分页,但它的缺点是不能自定义显示格式.而DataList解决了它的缺点,但DataList本身却不能分页.很是头痛,于是在 ...

  5. IDEA04 工具窗口管理、各种跳转、高效定位、行操作、列操作、live template、postfix、alt enter、重构、git使用

    1 工具窗口管理 所有的窗口都是在view -> tools windows 下面的,这些窗口可以放在IDEA的上下左右各个位置:右键某个窗口后选择move to 即可进行位置调整 2 跳转 2 ...

  6. 在 Bootstraptable 插件基础上新增可编辑行

    http://www.tuicool.com/articles/YbEVv2v 为什么调用 bootstraptable 原生方法会有问题 首先我必须肯定, bootstraptable 是一款很强大 ...

  7. 使用 PIVOT 和 UNPIVOT 行转列 列转行 报表统计 函数

    官方文档:http://technet.microsoft.com/zh-cn/library/ms177410(v=SQL.105).aspx 可以使用 PIVOT 和 UNPIVOT 关系运算符将 ...

  8. Oracle行转列(使用pivot函数)

    在日常使用中,经常遇到这样的情况,需要将数据库中行转化成列显示,如 转化为 这个时候,我们就需要使用pivot函数 百度后,参考网址http://www.2cto.com/database/20150 ...

  9. DB2行转列、列转行等操作

    DB2 行转列 ----start 在网上看到这样一个问题:(问题地址:http://www.mydb2.cn/bbs/read.php?tid=1297&page=e&#a) 班级  ...

  10. 大数据学习day28-----hive03------1. null值处理,子串,拼接,类型转换 2.行转列,列转行 3. 窗口函数(over,lead,lag等函数) 4.rank(行号函数)5. json解析函数 6.jdbc连接hive,企业级调优

    1. null值处理,子串,拼接,类型转换 (1) 空字段赋值(null值处理) 当表中的某个字段为null时,比如奖金,当你要统计一个人的总工资时,字段为null的值就无法处理,这个时候就可以使用N ...

随机推荐

  1. Android Studio打开现有的项目,Android自带的类、函数(方法)属性等爆红,含解决方式

    如上图,Android 自带的 setContentView 爆红,XML文件内 android:相关的属性(如android:layout_width) 爆红 原因: 使用Android Studi ...

  2. 移动端性能测试--CPU资源

    一.背景 在很多场景下我们去使用 App,可能会碰到手机会出现发热发烫的现象.这是因为 CPU 使用率过高.CPU 过于繁忙,会使得整个系统无法响应用户,整体性能降低,用户体验变得相当差,也容易引起 ...

  3. Job for nfs-server.service failed because the control process exited with error code. See "systemctl status nfs-server.service" and "journalctl -xe" for details.

    问题: 解决:

  4. Joseph Problem With Passwords In Java

    问题描述: 编号为1,2,......,n的n个人(每个人的信息有编号.姓名和密码三项)按照顺时针方向围坐一圈, 每个人有且只有一个密码(正整数,密码用随机方式赋值,范围1-15).一开始任选一个正整 ...

  5. js判断当值的比较小的背景为红色

    <!DOCTYPE html> <html> <head> <title></title> </head> <body&g ...

  6. React如何修改props && 子组件调用父组件方法

    /** * 子组件如何更改父组件的state呢? * 父组件传递下来的props不满足要求,往往需要修改 * * * Author: shujun * Date: 2020-10-25 */ impo ...

  7. canvas合并图片并长按保存

    代码实现 <div class="pho-bg"> <img src="../../assets/images/FeedbackActivity/pos ...

  8. python 快速搭建局域网文件服务器 SimpleHTTPServer http.server

    py2: python2 -m SimpleHTTPServer [port] py3:   python3 -m http.server [port] python2请注意大小写. 在Windows ...

  9. HCIP-进阶实验02-ISIS协议部署

    进阶实验02-ISIS协议部署 1 实验需求 设备 接口 IP地址 备注 R1 G0/0/0 10.1.123.1/24 R2 G0/0/0 10.1.123.2/24 G0/0/1 10.1.24. ...

  10. Typora的下载和MarkDown的相关操作

    MarkDown 作为程序员就要会写blog(网络日记),那么怎么让你的笔记写的排版舒适清晰?我们可以通过MarkDown来写笔记 首先我们要下载Typora,因为现在官网的Typora要付费,所以可 ...