当前位置: 首页 > news >正文

wordpress添加优酷视频无锡seo公司找哪家好

wordpress添加优酷视频,无锡seo公司找哪家好,邢台做移动网站价格,做网页初学者教程背景:最近在项目中有需求需要在DataGridView中添加“删除”、“修改”按钮,用来对数据的操作以及显示。 在DataGridView中显示需要的按钮 首先在DataGridView中添加需要的列,此列是用来存放按钮的。 然后在代码中“画”按钮。 if (e.Column…

背景:最近在项目中有需求需要在DataGridView中添加“删除”、“修改”按钮,用来对数据的操作以及显示。

在DataGridView中显示需要的按钮

 首先在DataGridView中添加需要的列,此列是用来存放按钮的。

然后在代码中“画”按钮。

if (e.ColumnIndex >= 0 && e.RowIndex >= 0){if (this.dgvwProdCode.Columns[e.ColumnIndex].Name == "act"){StringFormat sf = StringFormat.GenericDefault.Clone() as StringFormat;//设置重绘入单元格的字体样式sf.FormatFlags = StringFormatFlags.DisplayFormatControl;sf.Alignment = StringAlignment.Center;sf.LineAlignment = StringAlignment.Center;sf.Trimming = StringTrimming.EllipsisCharacter;e.PaintBackground(e.CellBounds, true);//重绘边框//设置要写入字体的大小System.Drawing.Font myFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));SizeF sizeDel = e.Graphics.MeasureString("删除", myFont);SizeF sizeMod = e.Graphics.MeasureString("修改", myFont);SizeF sizeIsEnable = e.Graphics.MeasureString("启用/禁用", myFont);float fDel = sizeDel.Width / (sizeDel.Width + sizeMod.Width + sizeIsEnable.Width); //float fMod = sizeMod.Width / (sizeDel.Width + sizeMod.Width + sizeIsEnable.Width);float fIsEnable = sizeIsEnable.Width / (sizeDel.Width + sizeMod.Width+ sizeIsEnable.Width);//设置每个“按钮的边界”RectangleF rectDel = new RectangleF(e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width * fDel, e.CellBounds.Height);RectangleF rectMod = new RectangleF(rectDel.Right, e.CellBounds.Top, e.CellBounds.Width * fMod, e.CellBounds.Height);RectangleF rectIsEnable = new RectangleF(rectMod.Right, e.CellBounds.Top, e.CellBounds.Width* fIsEnable, e.CellBounds.Height);e.Graphics.DrawString("删除", myFont, Brushes.Black, rectDel, sf); //绘制“按钮”e.Graphics.DrawString("修改", myFont, Brushes.Black, rectMod, sf);e.Graphics.DrawString("启用/禁用", myFont, Brushes.Black, rectIsEnable, sf);e.Handled = true;}}

以上代码是在DataGridView中可以显示需要的按钮。

给DataGridView添加事件,可以通过按钮来操作数据库

使用CellMouseClick方法来去执行事件。

 private void dgvwProdCode_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e){if (e.ColumnIndex >= 0 && e.RowIndex >= 0){Point curPosition = e.Location;//当前鼠标在当前单元格中的坐标if (this.dgvwProdCode.Columns[e.ColumnIndex].Name == "act"){Graphics g = this.dgvwProdCode.CreateGraphics();System.Drawing.Font myFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(134)));SizeF sizeDel = g.MeasureString("删除", myFont);SizeF sizeMod = g.MeasureString("修改", myFont);SizeF sizeIsEnable = g.MeasureString("启用/禁用", myFont);float fDel = sizeDel.Width / (sizeDel.Width + sizeMod.Width + sizeIsEnable.Width);float fMod = sizeMod.Width / (sizeDel.Width + sizeMod.Width + sizeIsEnable.Width);float fIsEnable = sizeIsEnable.Width / (sizeDel.Width + sizeMod.Width + sizeIsEnable.Width);Rectangle rectTotal = new Rectangle(0, 0, this.dgvwProdCode.Columns[e.ColumnIndex].Width, this.dgvwProdCode.Rows[e.RowIndex].Height);RectangleF rectDel = new RectangleF(rectTotal.Left, rectTotal.Top, rectTotal.Width * fDel, rectTotal.Height);RectangleF rectMod = new RectangleF(rectDel.Right, rectTotal.Top, rectTotal.Width * fMod, rectTotal.Height);RectangleF rectIsEnable = new RectangleF(rectMod.Right, rectTotal.Top, rectTotal.Width * fIsEnable, rectTotal.Height);//判断当前鼠标在哪个“按钮”范围内if (rectDel.Contains(curPosition))//删除{IProduct product = new ProductImpl();ProductInfoEntity productInfo = new ProductInfoEntity();productInfo.recipe = dgvwProdCode.Rows[e.RowIndex].Cells[1].Value.ToString();if (product.Delete(productInfo) > 0){this.dgvwProdCode.Rows.RemoveAt(e.RowIndex);MessageBox.Show("删除成功");}dgvwProdCode.Refresh();//刷新显示}else if (rectMod.Contains(curPosition))//修改{// FormProductOperate formProductOperate = new FormProductOperate();FormProductOperate formProductOperate = FormProductOperate.GetInstance();formProductOperate.Text = "修改产品";formProductOperate.btnAdd.Visible = false;formProductOperate.btnConfirm.Visible = true;formProductOperate.recipe = dgvwProdCode.Rows[dgvwProdCode.CurrentRow.Index].Cells[1].Value.ToString();formProductOperate.Show();dgvwProdCode.Refresh();//刷新显示}else if (rectIsEnable.Contains(curPosition)){IProduct product = new ProductImpl();//获取选中产品记录产品idstring recipe = dgvwProdCode.Rows[dgvwProdCode.CurrentRow.Index].Cells[1].Value.ToString();if (product.UpdateStatus(recipe) > 0){UpDataViewSource();MessageBox.Show("状态更改成功");}}}}}

在按钮上鼠标箭头变成小手样式

使用CellMouseMove方法

private void dgvwProdCode_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e){if (e.ColumnIndex >= 0 && e.RowIndex >= 0){Point curPosition = e.Location;//当前鼠标在当前单元格中的坐标if (this.dgvwProdCode.Columns[e.ColumnIndex].Name == "act"){this.Cursor = Cursors.Hand;//解决绘图时画面闪烁SetStyle(ControlStyles.UserPaint, true);SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲}}}

这样在DataGridView中完整的按钮和操作就完成。以及样式上的修改。

http://www.hkea.cn/news/885832/

相关文章:

  • 可以上传图片的网站怎么做百度关键词点击
  • 泉州网站制作广州seo网站开发
  • cuntlove wordpressseo外链发布工具
  • 购买一个网站空间如何可以多个域名使用吗长沙网站建设服务
  • 天津市建设委员会网站上海网站制作开发
  • 扬中网站建设墨子学院seo
  • 分析电子商务网站建设需求教案青岛今天发生的重大新闻
  • 汕头模板开发建站百度发布信息怎么弄
  • 健身网站开发项目总结关键词筛选工具
  • 重庆网站建设零臻靠谱国内永久免费的云服务器
  • 软件库合集软件资料2024郑州百度快照优化
  • 房地产开发公司网站建设方案seo去哪里学
  • 做网站可以赚钱吗百度小说搜索风云排行榜
  • 做网站交接需要哪些权限网站seo视频教程
  • 在网站怎么做收款二维码刷移动关键词优化
  • 问信息奥赛题怎么做 去哪个网站互联网网络推广
  • b2c电子商务网站系统下载专业网站seo推广
  • 引流推广的方法seo诊断工具
  • 平阴县建设工程网站直通车推广怎么做
  • 网站开发外包不给ftp高佣金app软件推广平台
  • 太原适合网站设计地址百度用户服务中心客服电话
  • 济南源码网站建设长沙网站seo推广公司
  • 北京网站制作17页和业务多一样的平台
  • 无锡市住房城乡建设委网站简单网页设计模板html
  • 武汉市大型的网站制作公司网站ip查询
  • 做仪表行业推广有哪些网站电商网站设计
  • 动静分离网站架构百度售后客服电话24小时
  • 做汽车配件生意的网站佛山seo关键词排名
  • 创意建站推荐百度做广告多少钱一天
  • 巴中网站建设公司百度seo怎么做网站内容优化