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

win8 网站模板好看的模板

win8 网站模板,好看的模板,怎么创建属于自己的网站,怎么手动安装网站程序实现原因 因为现有的DataGridView控件无法支持在单元格DataGridViewCell上显示多个甚至是多种类型的控件 实现效果 效果1 效果2 实现代码 核心代码实现 using System; using System.Drawing; using System.Windows.Forms;namespace DataGridViewCellExtLib {/// summary…实现原因 因为现有的DataGridView控件无法支持在单元格DataGridViewCell上显示多个甚至是多种类型的控件 实现效果 效果1 效果2 实现代码 核心代码实现 using System; using System.Drawing; using System.Windows.Forms;namespace DataGridViewCellExtLib {/// summary/// DataGridViewCell扩展类/// /summarypublic static class DataGridViewCellExtension{/// summary/// 添加Panel控件到DataGridView/// /summary/// param namecellDataGridViewCell对象/param/// param namedataGridViewDataGridView对象/param/// returns返回已指定好大小位置添加到DataGridView控件的Panel对象/returns/// exception crefArgumentNullException/// 如果cell为Null抛出ArgumentNullException异常/// 如果dataGridView为Null抛出ArgumentNullException异常/// /exceptionpublic static Panel AddPanelControl(this DataGridViewCell cell, DataGridView dataGridView){if (cell null){throw new ArgumentNullException(nameof(cell));}if (dataGridView null){throw new ArgumentNullException(nameof(dataGridView));}var panel new Panel{//默认Panel颜色为透明BackColor Color.Transparent};//添加控件到DataGridViewdataGridView.Controls.Add(panel);//获取单元格的矩形范围Rectangle rectangle dataGridView.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, false);//设置Panel的大小panel.Size new Size(){Width rectangle.Width,Height rectangle.Height};//显示Panelpanel.Visible true;//设置Panel位置panel.Location new Point(rectangle.Left, rectangle.Top);//将Panel和DataGridViewCell绑定在一起panel.Tag new TagPlusDataGridViewCell{Binding cell};cell.Tag new TagPlusPanel{Binding panel};return panel;}/// summary/// 从DataGridView中移除Panel控件/// /summary/// param namecellDataGridViewCell对象/param/// param namedataGridViewDataGridView对象/param/// exception crefArgumentNullException/// 如果cell为Null抛出ArgumentNullException异常/// 如果dataGridView为Null抛出ArgumentNullException异常/// /exceptionpublic static void RemovePanelControl(this DataGridViewCell cell, DataGridView dataGridView){if (cell null){throw new ArgumentNullException(nameof(cell));}if (dataGridView null){throw new ArgumentNullException(nameof(dataGridView));}var panel ((TagPlusPanel)cell.Tag).Binding;//移除Panel控件dataGridView.Controls.Remove(panel);panel.Dispose();}/// summary/// 重新在DataGridView控件中设置Panel位置/// /summary/// param namecellDataGridViewCell对象/param/// param namedataGridViewDataGridView对象/param/// exception crefArgumentNullException/// 如果cell为Null抛出ArgumentNullException异常/// 如果dataGridView为Null抛出ArgumentNullException异常/// /exceptionpublic static void ResetPanelControlLocation(this DataGridViewCell cell, DataGridView dataGridView){if (cell null){throw new ArgumentNullException(nameof(cell));}if (dataGridView null){throw new ArgumentNullException(nameof(dataGridView));}var tagPlus (TagPlusPanel)cell.Tag;var panel tagPlus.Binding;//获取单元格的矩形范围Rectangle rectangle dataGridView.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, false);//设置Panel位置panel.Location new Point(rectangle.Left, rectangle.Top);}}/// summary/// Tag扩展类/// /summary/// typeparam nameT需要绑定的数据类型/typeparampublic class TagPlusT{/// summary/// 需要绑定的元素/// /summarypublic T Binding { get; set; }/// summary/// 将Control.Tag属性保留到当前属性上/// /summarypublic object Tag { get; set; }} }程序代码地址下载 https://gitee.com/GandalfGao/cell-with-control.git 设计思路 1. 为什么以DataGridViewCell的扩展类方式实现 从界面的实现角度来看控件是添加到单元格中的实际却不是这样的添加显示的控件实际和DataGridViewCell一点关系都没有它们也没有父级和子级的关系添加的控件只和DataGridView控件有父级和子级的关系。因此我想设计一个这样的扩展方法使其开发起来就好像是直接对DataGridViewCell操作一样 比如添加控件虽然实际是往DataGridView控件上做添加但是开发者在用扩展方法时就仿佛是在对DataGridViewCell做添加一样这样的话在感官上显得更加直接 2. 为什么添加到DataGridView的都是只是一个Panel控件 a. 是为了化繁为简 我需要设计一个root的控件用这个控件来承接多个甚至是多个不同种类的子控件。这样的设计的好处有两点 第一对于DataGridViewCell来说只需要面对这一个root控件即可它不需要再关注root控件里面究竟设计了什么样的控件它们的位置是在哪里。它只需要对一个控件做好负责那就是这个root控件只要设计好这个root的控件大小和其位置就可以了大小是单元格的大小位置是单元格的位置 第二设计这个root控件之后子控件的位置就是相对root控件位置来设置了不需要再相对DataGridView控件位置来设置。 b. 为什么选择Panel做为这个root控件 因为子控件在Panel控件中布局更加简单和自由 3. TagPlus类是做什么用的 简单来说Control类中带有Tag属性TagPlus可以理解为是Tag属性的扩展版 那为什么需要这个类来做为Tag的扩展呢 这就得提到我其中的一个设计思路。由于DatGridViewCell控件和Panel控件之间没有关联关系而是DataGridView控件和Panel有关联关系且是一对多的关系。所以我就想通过某种方式将DataGridViewCell控件和Panel控件绑定在一起让它们之间有一定关联关系且是一对一的关联关系首先想到的就是用Control的Tag属性但是担心Tag属性被占用后如果想要添加别的数据到Tag上那就无法赋值了所以我加了TagPlus类在提供绑定控件属性的同时且也保留了Tag属性。绑定之后呢DataGridViewCell和Panel就有了关联关系DataGridViewCell就成了Panel逻辑上的“父控件”Panel成了DataGridViewCell逻辑上的“子控件”这样也更好的可以通过DataGridViewCell去访问到Panel控件通过Panel控件更好的访问到DataGridViewCell控件。 结尾 如果您觉得我还写的不错请给我一点点的鼓励您的鼓励就是我坚持的动力当然啦一切要量力而行不要勉强哦
http://www.dnsts.com.cn/news/101238.html

相关文章:

  • 镇平县建设局网站乐清站在那儿
  • 网站建设的外文参考文献商标设计网站是哪个
  • 大庆建设集团网站只会后端不会前端如何做网站
  • 免费样机素材网站阿里云空间部署网站
  • 电商网站 厦门重庆工程网站建设
  • 沟通交流型网站广告如何做网站建设的大纲
  • 网站建设详细描述产品的是什么意思北京营销网站建设公司
  • 怎样拍照产品做网站wordpress使用不同的页头
  • 哪里有做网站培训的安顺网站建设兼职
  • 做网站首选科远网络wordpress 去掉描述的超链接
  • 王璐 牟平 网站建设网站模板免费下载中文版
  • 衡水哪个公司做网站好学校网站建设问卷调查表
  • 成都建设网站哪个好服装网站建设的规模和类别
  • 站长之家网站介绍做360手机网站优化快
  • 腾讯分分彩做号网站成都网站建设时代汇创
  • 二级域名网站优化网页设计作业成品代码和文字
  • 招商局网站建设管理总结宣传旅游网站建设
  • 网站备案 选项织梦cms首页模板文件是哪个
  • 免费网站根目录易企秀h5怎么制作
  • 没有域名网站吗mvc5网站开发之美电子版
  • 网站 维护 费用网站被备案能建设
  • 南昌网站建设公司行情企业宣传推广
  • 有了网址可以建网站吗seo优化网站推广全域营销获客公司
  • 网站建设有那几个类型松江专业做网站公司
  • 北京微网站有没有做网站的软件
  • 上海专业网站建设报价单怎么给自己的网站设置关键词
  • 可以建网站的路由器论坛网站开发费用
  • 保定专业网站建设开发公司计算机培训班哪些好
  • 用凡科做网站要钱吗WordPress自定义tag模板
  • 地理云门户网站建设duplicator wordpress