DataGridView使用技巧(集)

C# DataGridView合并单元格 private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.Value.ToString() != string.Empty) { //if (!s. 阅读详情

DataGridView使用技巧大全

收集一些在DataGridVeiw使用技巧,备用。

一、DataGridView 单元格验证

1、定义单元格验证
要求:验证错误后焦点不离开。
实现:
单元格的验证可以使用dgv_details_CellValidating事件。
验证不通过时调用e.Cancel = true;终止事件链,单元格将保持编辑状态。
调用dgv_details.CancelEdit();可以使单元格的内容会滚到修改前的值。
使用System.Windows.Forms.SendKeys.Send("^a");将全选单元格的内容。

2、单元格选中并开始编辑状态
实现:

  1. //DataGridView获得焦点
  2. dgv_details.Focus();
  3. //DataGridView指定当前单元格
  4. dgv_details.CurrentCell = dgv_details[0, 0];
  5. //开始编辑状态
  6. dgv_details.BeginEdit(false);

3、定制自动生成绑定了列
实现:

  1. dgv_details.AutoGenerateColumns = false;

4、设置列的背景色
实现:

    • Color GridReadOnlyColor = Color.LightGoldenrodYellow;
    • dgv_details.Columns[1].DefaultCellStyle.BackColor = WinKeys.GridReadOnlyColor;

5、DataGridView单元格验证的设计的问题
问题:绑定还是不绑定?
1)绑定的优势:比较简单,代码少。
2)绑定得缺点:DataGridView中的数据受数据源的影响(主键约束、值类型约束)。不一至时会激发DataError事件,输入的内容无法保存到单元格中和数据源中。特殊的验证(比如长度、格式等)还是需要另外写代码实现。
关于增加行的问题。增加新行时多主键的验证有问题,而且验证不通过时会将新行全部删除。限制很多,很不方便。
3)非绑定的优势:验证等处理比较灵活。不受数据源的约束。
4)非绑定得缺点:显示和向数据库更新数据时需要比较多的代码实现,效率比较低。
5)总的感觉在处理验证比较麻烦的场合,我还是比较喜欢非绑定的方式。如果数据量大,验证比较简单的场合使用绑定模式比较好。

二、DataGridView重绘代码

1、CellFormatting事件,一般重绘单元格属性。

  1.    private Bitmap highPriImage;
  2.     private Bitmap mediumPriImage;
  3.     private Bitmap lowPriImage;
  4. private void dataGridView1_CellFormatting(object sender, 
  5.         System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
  6.     {
  7.         // Set the background to red for negative values in the Balance column.
  8.         if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Balance"))
  9.         {
  10.             Int32 intValue;
  11.             if (Int32.TryParse((String)e.Value, out intValue) && 
  12.                 (intValue < 0))
  13.             {
  14.                 e.CellStyle.BackColor = Color.Red;
  15.                 e.CellStyle.SelectionBackColor = Color.DarkRed;
  16.             }
  17.         }
  18.         // Replace string values in the Priority column with images.
  19.         if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Priority"))
  20.         {
  21.             // Ensure that the value is a string.
  22.             String stringValue = e.Value as string;
  23.             if (stringValue == null) return;
  24.             // Set the cell ToolTip to the text value.
  25.             DataGridViewCell cell = dataGridView1[e.ColumnIndex, e.RowIndex];
  26.             cell.ToolTipText = stringValue;
  27.             // Replace the string value with the image value.
  28.             switch (stringValue)
  29.             {
  30.                 case "high":
  31.                     e.Value = highPriImage;
  32.                     break;
  33.                 case "medium":
  34.                     e.Value = mediumPriImage;
  35.                     break;
  36.                 case "low":
  37.                     e.Value = lowPriImage;
  38.                     break;
  39.             }
  40.         }
  41.     }

2、CellPainting事件,一般用于合并单元格用
Windows Forms DataGridView 没有提供合并单元格的功能,要实现合并单元格的功能就要在CellPainting事件中使用Graphics.DrawLine和 Graphics.DrawString 自己来“画”。
下面的代码可以对DataGridView第1列内容相同的单元格进行合并:

  1. #region"合并单元格的测试"
  2. private int? nextrow = null;
  3. private int? nextcol = null;
  4. private void dataGridView1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
  5. {
  6.     if (this.dataGridView1.Columns["description"].Index == e.ColumnIndex && e.RowIndex >= 0)
  7.     {
  8.         if (this.nextcol != null & e.ColumnIndex == this.nextcol)
  9.         {
  10.             e.CellStyle.BackColor = Color.LightBlue;
  11.             this.nextcol = null;
  12.         }
  13.         if (this.nextrow != null & e.RowIndex == nextrow)
  14.         {
  15.             e.CellStyle.BackColor = Color.LightPink;
  16.             this.nextrow = null;
  17.         }
  18.         if (e.RowIndex != this.dataGridView1.RowCount - 1)
  19.         {
  20.             if (e.Value.ToString() == this.dataGridView1.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value.ToString())
  21.             {
  22.                 e.CellStyle.BackColor = Color.LightPink;
  23.                 nextrow = e.RowIndex + 1;
  24.             }
  25.         } 
  26.     }
  27.     if (this.dataGridView1.Columns["name"].Index == e.ColumnIndex && e.RowIndex >= 0)
  28.     {
  29.         if (e.Value.ToString() == this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString())
  30.         {
  31.             e.CellStyle.BackColor = Color.LightBlue;
  32.             nextcol = e.ColumnIndex + 1;
  33.         }
  34.     }
  35. }
  36. //==========================
  37.        
  38. //绘制单元格
  39. private void dataGridView1_CellPainting(object sender, System.Windows.Forms.DataGridViewCellPaintingEventArgs e)
  40. {
  41.     //纵向合并
  42.     if (this.dataGridView1.Columns["description"].Index == e.ColumnIndex && e.RowIndex >= 0)
  43.     {
  44.         using (
  45.             Brush gridBrush = new SolidBrush(this.dataGridView1.GridColor),
  46.             backColorBrush = new SolidBrush(e.CellStyle.BackColor))
  47.         {
  48.             using (Pen gridLinePen = new Pen(gridBrush))
  49.             {
  50.                 // 擦除原单元格背景
  51.                 e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
  52.                 ////绘制线条,这些线条是单元格相互间隔的区分线条,
  53.                 ////因为我们只对列name做处理,所以datagridview自己会处理左侧和上边缘的线条
  54.                 if (e.RowIndex != this.dataGridView1.RowCount - 1)
  55.                 {
  56.                     if (e.Value.ToString() != this.dataGridView1.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value.ToString())
  57.                     {
  58.                         e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1,
  59.                         e.CellBounds.Right - 1, e.CellBounds.Bottom - 1);//下边缘的线
  60.                         //绘制值
  61.                         if (e.Value != null)
  62.                         {
  63.                             e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  64.                                 Brushes.Crimson, e.CellBounds.X + 2,
  65.                                 e.CellBounds.Y + 2, StringFormat.GenericDefault);
  66.                         }
  67.                     }
  68.                 }
  69.                 else
  70.                 {
  71.                     e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1,
  72.                         e.CellBounds.Right - 1, e.CellBounds.Bottom - 1);//下边缘的线
  73.                     //绘制值
  74.                     if (e.Value != null)
  75.                     {
  76.                         e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  77.                             Brushes.Crimson, e.CellBounds.X + 2,
  78.                             e.CellBounds.Y + 2, StringFormat.GenericDefault);
  79.                     }
  80.                 }
  81.                 //右侧的线
  82.                 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
  83.                     e.CellBounds.Top, e.CellBounds.Right - 1,
  84.                     e.CellBounds.Bottom - 1);
  85.                 e.Handled = true;
  86.             }
  87.         }
  88.     }
  89.     //横向合并
  90.     if (this.dataGridView1.Columns["name"].Index == e.ColumnIndex && e.RowIndex >= 0)
  91.     {
  92.         using (
  93.             Brush gridBrush = new SolidBrush(this.dataGridView1.GridColor),
  94.             backColorBrush = new SolidBrush(e.CellStyle.BackColor))
  95.         {
  96.             using (Pen gridLinePen = new Pen(gridBrush))
  97.             {
  98.                 // 擦除原单元格背景
  99.                 e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
  100.                 if (e.Value.ToString() != this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString())
  101.                 {
  102.                     //右侧的线
  103.                     e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, e.CellBounds.Top,
  104.                         e.CellBounds.Right - 1, e.CellBounds.Bottom - 1);
  105.                     //绘制值
  106.                     if (e.Value != null)
  107.                     {
  108.                         e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  109.                             Brushes.Crimson, e.CellBounds.X + 2,
  110.                             e.CellBounds.Y + 2, StringFormat.GenericDefault);
  111.                     }
  112.                 }
  113.                 //下边缘的线
  114.                 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1,
  115.                                             e.CellBounds.Right - 1, e.CellBounds.Bottom - 1);
  116.                 e.Handled = true;
  117.             }
  118.         }
  119.     }
  120. }
  121. #endregion

三、在GridView中如何格式化Money型字段(downmoon)?

  1.         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PKID"
  2.             DataMember="DefaultView" DataSourceID="SqlDataSource1">
  3.             <Columns>
  4.                 <asp:BoundField DataField="PKID" HeaderText="PKID" InsertVisible="False" ReadOnly="True"
  5.                     SortExpression="PKID" />
  6.                 
  7.                 <asp:TemplateField>
  8.                         <HeaderTemplate>
  9.                            amount</HeaderTemplate>
  10.                         <ItemTemplate>
  11.                             <asp:Label ID="txtMoney" Text='<%# Decimal.Parse(DataBinder.Eval(Container.DataItem,"amount").ToString())%>' runat="server" />
  12.                         </ItemTemplate>
  13.                     </asp:TemplateField>
  14.                 <asp:BoundField DataField="TestID" HeaderText="TestID" SortExpression="TestID" />
  15.                 <asp:BoundField DataField="testString" HeaderText="testString" SortExpression="testString" />
  16.             </Columns>
  17.         </asp:GridView>

这段代码中,
amount为Money型字段,无论如何只能显示成
1234.5600 
而不能显示成
1,234.56
用

  1. <asp:BoundField DataField="amount" HeaderText="amount" DataFormatString="{0:n2}"  />
  2.                    <asp:BoundField DataField="amount" HeaderText="amount" DataFormatString="{0:c2}"  />

也不行!
后来在MSDN上找到了答案

  1. <asp:BoundField DataField="amount" HeaderText="amount" DataFormatString="{0:#,###.00}"  HtmlEncode="False" />

关键在于HtmlEncode="False"

http://blogs.msdn.com/danielfe/archive/2006/02/08/527628.aspx

(源文:http://blog.youkuaiyun.com/downmoon/archive/2007/11/01/1860611.aspx)

四、DataGridView合并单元格 编辑单元格

同事的一个项目需要将DataGridView单元格中的内容分不同颜色显示,想了想只有重绘了。
这种方法还可以用做合并单元格。

参考代码:

  1. private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  2.         {
  3.             if (e.RowIndex == 0 && e.ColumnIndex >= 0)
  4.             {
  5.                 int left = e.CellBounds.Left;
  6.                 int top = e.CellBounds.Top;
  7.                 int right = e.CellBounds.Right;
  8.                 int bottom = e.CellBounds.Bottom;
  9.                 e.Graphics.FillRectangle(new SolidBrush(Color.White), e.CellBounds);
  10.                 e.Handled = true;
  11.                 Brush gridBrush = new SolidBrush(this.dataGridView1.GridColor);
  12.                 Pen gridLinePen = new Pen(gridBrush);
  13.                 e.Graphics.DrawLine(gridLinePen, right - 1,
  14.                            top, right - 1,
  15.                            bottom - 1);
  16.                 e.Graphics.DrawLine(gridLinePen, left,
  17.                            bottom - 1, right,
  18.                            bottom - 1); 
  19.                 Brush b1 = new SolidBrush(Color.Black);
  20.                 e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  21.                                         b1, left + 2,
  22.                                         top + 1, StringFormat.GenericDefault); 
  23.                 Brush b2 = new SolidBrush(Color.Red);
  24.                 e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  25.                                         b2, left + 2,
  26.                                         top + 10, StringFormat.GenericDefault);
  27.             } 
  28.             DataGridViewSelectedCellCollection dgvscc = this.dataGridView1.SelectedCells;
  29.             foreach (DataGridViewCell dgvc in dgvscc)
  30.             {
  31.                     if (e.RowIndex == 0 
  32.                         && e.RowIndex == dgvc.RowIndex 
  33.                         && e.ColumnIndex == dgvc.ColumnIndex)
  34.                     {
  35.                         int left = e.CellBounds.Left;
  36.                         int top = e.CellBounds.Top;
  37.                         int right = e.CellBounds.Right;
  38.                         int bottom = e.CellBounds.Bottom;
  39.                         // 绘制背景,覆盖单元格区域
  40.                         e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(10,36,106)), e.CellBounds);
  41.                         
  42.                         // 绘制边框
  43.                         Brush gridBrush = new SolidBrush(this.dataGridView1.GridColor);
  44.                         Pen gridLinePen = new Pen(gridBrush);
  45.                         e.Graphics.DrawLine(gridLinePen, right - 1,
  46.                                    top, right - 1,
  47.                                    bottom - 1);
  48.                         e.Graphics.DrawLine(gridLinePen, left,
  49.                                    bottom - 1, right,
  50.                                    bottom - 1); 
  51.                         // 绘制文字
  52.                         Brush b1 = new SolidBrush(Color.White);
  53.                         e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  54.                                                 b1, left + 2,
  55.                                                 top + 1, StringFormat.GenericDefault); 
  56.                         Brush b2 = new SolidBrush(Color.White);
  57.                         e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
  58.                                                 b2, left + 2,
  59.                                                 top + 10, StringFormat.GenericDefault);
  60.                     }
  61.             } 
  62.             e.Handled = true;            
  63.         }

感谢各位作者。

 

 

 

C# DataGridView单元格合并居中 标题 private void D1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { string text = string.Empty; // 对第1,2行相同单元格进行合并 if (e.RowIndex <= 1 && e.ColumnIndex <= D1.Columns.Count - 1 && e.ColumnIndex > 0) 阅读详情

相关推荐

【2019-06-21】C# DataGridView单元格结合

大家好,这是是雨夜,一位刚入行的萌新。刚刚开通了属于自己的优快云博客。以后会把自己工作上遇到的一些问题都通过博客的方式记录、分享出来,与大家一同探讨进步。 最近公司的需求是要把winform的datagridview的同一字段的相同内容的单元格合并,但是在把datagridview的内容输出到EXCEL时则是未合并的状态。在网上查询了很多资料,绝大部分的做法就是使用datag...

shana13955036039的博客 754

Winform的DataGridView单元格自定义显示(CellPainting)

我们低代码开发平台免费开放后,收到最大的需求就是“单据转换”,主要是我们以前所面对的行业的需求压根没法通过单据转换这样的配置来实现,所以我们一直都是用后台插件的形式处理他们的个性化计算,转换需求。但是免费开放后,面对的都是各种各样的行业,有很多需求用单据转换确实更简单和容易些。所以昨天有朋友看了我们截图后私信想了解下我们图片上的“日期字段”的格式化按钮怎么做的。我们采用了流程化的方式来实现单据转换,同一个单据可以支持多个转换流程,每个流程支持多个转换节点,每个节点完成不同的转换需求,逻辑很合理。

老田低代码 2769

【VB.net】DataGridView控件的使用

VS中的DataGridView控件,在机房重构里的出镜率还是很高哒~这篇博客就把一些有关DataGridView 控件的一些使用细节和大家分享一下!   找到控件:                                                                                                

王璐 2万+

DataGridView 中单元格显示不一样颜色方法

1、DataGridView  中添加CellPainting事件方法 2、在CellPainting函数内部进行重绘

wangdaoyin2010的专栏 8104

Python金融数据获取工具库之baostock使用详解

在金融数据分析和量化交易中,获取准确及时的市场数据是非常重要的。baostock是一个专门为中国股市数据提供支持的 Python 库,它提供了免费的股票数据接口,用户可以方便地获取股票、指数、基金等各种金融数据。本文将详细介绍baostock库,包括其安装方法、主要特性、基本和高级功能,以及实际应用场景,帮助全面了解并掌握该库的使用。

Rocky006的博客 5343

电路仿真软件PSIM简介

PSIM的基本使用操作...

qq_55203246的博客 7175

dataGridView使用技巧

1、错误提示:当前进程正另一个进程冲突了。原因是你的程序之前没有正常关闭,导致出现僵尸进程。必须用任务管理器将这个僵尸进程杀掉、结束才行 2、编程的时候所有文件夹、变量、命名空间、项目名称一定要使用英文、拼音 来命名。否则一出现问题很难处理。严禁直接使用汉字、数字来命名 3、要充分利用好VS的代码提示功能 。 4、DBHelper会使程序非常简单 ,里面只有5个方法(1个方法用来连接数据库、1个方法用来执行增删改的sql语句、3个方法用来执行查询(读取器、适配器返回的是DataTabel、聚合函

lelexingyu的博客 2015

Chipyard------介绍与环境搭建

Chipyard是一个开源的、可扩展的、集成化的芯片设计平台,旨在帮助芯片设计人员快速、高效地开发自己的定制芯片。由伯克利大学架构研究小组开发,它基于Chisel语言和Scala编程语言,提供了一整套硬件设计工具和流程,包括RTL设计、验证、物理布局、仿真等,以及支持多种芯片体系结构的库和模块。

qq_38798111的博客 9479

DataGridView使用技巧

收集一些在DataGridVeiw使用技巧,备用。 一、DataGridView 单元格验证 1、定义单元格验证 要求:验证错误后焦点不离开。 实现: 单元格的验证可以使用dgv_details_CellValidating事件。 验证不通过时调用e.Cancel = true;终止事件链,单元格将保持编辑状态。 调用dgv_details.CancelEdit

hduzh的专栏 1530

使用 Simulink + Simscape Electrical 实现一个三相半控桥式整流器的仿真模型

本文详细介绍了使用Simulink搭建三相半控桥式整流器仿真模型的方法。主要内容包括系统结构设计、建模步骤(从创建项目到参数配置)、移相触发控制的实现,以及阻感负载下的动态响应分析。通过合理设置三相电源、整流器模块、触发控制和测量模块,实现了输出电压和电流波形的仿真观测。文章还提供了优化建议,如添加滤波器、实时控制等改进方向,为电力电子变换器的仿真研究和性能优化提供了实用指导。

amy_mhd的博客 139

Python 爬虫教程:抓取视频平台数据(观看量、评论数、点赞数等)

爬虫(Crawler)是通过编写程序模拟浏览器行为,从互联网上抓取并提取信息的技术。爬虫的核心任务是模拟用户访问网页,获取网页内容并解析出我们需要的数据。爬虫技术被广泛应用于搜索引擎、数据分析、电商价格监控、内容抓取等领域。Bilibili和YouTube。这两个平台都提供丰富的用户生成内容(UGC),且在中国和全球范围内都非常流行。Bilibili:以二次元文化为主的视频平台,用户活跃,视频内容丰富。Bilibili的网页数据较为简单,可以通过传统的HTML解析抓取。YouTube。

2201_76125261的博客 1854

datagridview的使用及小技巧

1、绑定数据SqlDataAdapter objDa = new SqlDataAdapter("SELECT ID , BGQHL , BGHDL, BGXZKD, BGYZMJ, BZ FROM META_BGRule", connect);//connect 是数据库连接串            if (objDa != null)            {                D

NewMap的专栏 1380

flash均衡磨损--实时保存设备数据

【代码】flash均衡磨损--实时保存设备数据。

Car12 480

C#中dataGridView用法集

最近用到数据库的DataGridView控件 从网上转载了这篇文章看看还是很有帮助的 SqlConnection conn = new SqlConnection('Server=(local);DataBase=test;User=sa;Pwd=sa'); SqlDataAdapter da = new SqlDataAdapter('select * from test', conn); DataSet ds = new DataSet(); da.Fill(ds); dataGridView1.Dat

sc20031024的博客 7468

2. Android_逆向的历史与发展

学完本节,希望你能够:了解 Android 逆向工程的发展历程,从早期 APK 破解到现代应用保护;入门先把这几类「在干啥」搞清楚,后面学脱壳、反反调试会顺很多。(反编译 APK 得到的类汇编代码,相当于程序的「菜谱」)就能绕过验证,到后来混淆、加固、反调试一起上,逆向难度越来越高。(第三节 什么是 CPU 指令集),帮你搞清楚「反汇编看到的那些指令」是从哪来的、和 Android 逆向有啥关系。有必要——先搞清「没加固时怎么玩」,再学脱壳和对抗,思路才顺。读起来费劲,但逻辑还在,耐心一点还能跟。

长沙火山 1390

机器人控制基础:伺服驱动器的泄放电阻

摘要:伺服驱动器泄放电阻用于消耗电机减速或制动时产生的再生电能,防止母线电压过高损坏元件。其核心作用是将多余电能转化为热能,规避硬件损坏和停机风险。选型需关注功率、阻值和封装三大参数,功率应匹配再生能量,阻值需符合驱动器要求,封装应满足散热需求。可通过动态监测母线电压或静态检测电阻阻值来判断其是否正常工作。

start_up_go的博客 381

DataGridView的几个技巧

DataGridView是一个强大而灵活的数据显示编辑控件.网上流传着大量简单而且实用的于DataGridView有关的开发技巧.不过,要从纷繁杂乱的网络资源中筛选出自己真正需要的也并不是一件省心省力的事.因此,这里将平时常用的几个DataGridView技巧整理出来,供有需要的朋友参考. 先用图片来说明本文将要涉及到的相关技巧吧: 一,数据列计数与汇总的计算 还是先看一

Lucker's PowerSpace 3258

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

把一个DATAGRIDVIEW中的行复制到另个DATAGRIDVIEW中

 本人最近编程,需要把一个DATAGRIDVIEW中的数据复制到另一个DATAGRIDVIEW中,经过三天的研究,终于有了一个自己满意的解决办法,现在写出来给大家分享一下。首先让大家看看界面:然后定义一个数据库连接的方法和一个数据库连接对象:private SqlConnection con;        public SqlConnection Conn()  

zhangyu1428_hi的专栏 5923

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

DataGridview一些技巧总结

 最近一直跟DataGridView打交道,突然觉得很多技巧性的东西很模糊,经过最近的个人实验操作和从网上查到的资料把对DataGridView操作的一些技巧总结和借鉴了一下,总结如下:1、自定义列   Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Th

406

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

for foreach遍历datagridview行集不一样

3.遍历DataGridView行集:用foreach和用for来遍历DataGridView行集的效果是不一样的。区别在于,用foreach,会遍历到用foreach的Header,而用用for来遍历却不会。

sclxf的专栏 3313

DataGridView的一些技巧

DataGridView的一些技巧最近一直跟DataGridView打交道,突然觉得很多技巧性的东西很模糊,经过最近的个人实验操作和从网上查到的资料<br />把对DataGridView操作的一些技巧总结和借鉴了一下,总结如下:<br /><br />1、自定义列   Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their    Behavior and Appearance    H

lulugl的专栏 330
上一篇: 常用SQL语句实例大全(含过滤及删除重复数据、导入导出数据等)
下一篇: Visual C# 中智能提示(XML注释)的使用(含注释在开发时显示换行)
wonsoft
博客等级 码龄23年 228粉丝 98原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值