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

在网站上保存网址怎么做龙岩上杭县

在网站上保存网址怎么做,龙岩上杭县,宁波pc营销型网站制作,亳州网站开发转载#xff1a; http://blog.163.com/zjlovety126/blog/static/2241862420106128264300/ 也不知道是否该应用这个控件#xff0c;不过也想不出该用其他什么控件#xff0c;关键是俺比较菜没什么经验。 要求是这样的#xff0c;用户一次添加一个任务#xff0c;这个任务有…转载 http://blog.163.com/zjlovety126/blog/static/2241862420106128264300/ 也不知道是否该应用这个控件不过也想不出该用其他什么控件关键是俺比较菜没什么经验。 要求是这样的用户一次添加一个任务这个任务有三个选项其中两个选项是用户动态输入的名称就象图中bb和dd两列另一个选项则是一堆数据就象qq那列我现在要把每个任务罗列出来不能用treeview不能用tabcontrol不能用xml最好象个表格一样清晰明朗疯了每个任务对应两个按钮一个是Run为了跑任务一个是Remove为了移除任务。     当然最开始选择DataGridView就是为了满足那个“象表格一样清晰明朗”的奇怪需求一行对应一个任务其次貌似DataGridView控件在.net 2.0中加入了新的特征如DataGridViewButtonColumn啊DataGridViewComboBoxColumn之类的东东。研究了一天才发现这两个东东根本派不上用场首先DataGridViewButtonColumn中的Button跟真的Button根本没得比既不能添加Button的Text也不好添加Click事件应该是有方法的但还是很别扭而且也没研究其次是DataGridViewComboBoxColumn不仅外观上不能和真正的ComboBox相提并论而且当你选择了其中的任一itemDataGridView就会新增一行这跟我们的需求是完全不符合的毕竟一个选项是不能代表一个任务的。 从网上查了很多资料呵呵看到一篇说可以画个控件上去觉得很有意思。其实我就是这么做的。 1首先初始化DataGridView控件。 private void Form1_Load(object sender, EventArgs e) { DataGridViewCellStyle columnHeaderStyle  new DataGridViewCellStyle();             columnHeaderStyle.BackColor  Color.Beige;             columnHeaderStyle.Font  new Font(Verdana, 10, FontStyle.Bold);             dataGridView1.ColumnHeadersDefaultCellStyle columnHeaderStyle;             this.dataGridView1.Columns.Add(1, bb);             this.dataGridView1.Columns.Add(2, qq);             this.dataGridView1.Columns.Add(3, dd);             this.dataGridView1.Columns.Add(4, aa); } 2单击按钮添加一行包括单元格和单元格的值看似内嵌在单元格中的按钮和下拉列表 private void button4_Click(object sender, EventArgs e) {             DataGridViewRow dr  new DataGridViewRow();             foreach (DataGridViewColumn c in this.dataGridView1.Columns)             {                 dr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);  //给行添加单元格             } dr.Cells[0].Value  1111;             dr.Cells[2].Value  3333;             this.dataGridView1.Rows.Add(dr);             int index  this.dataGridView1.Rows.Count - 2;               ComboBox com  new ComboBox();             com.Name  Containers  index.ToString(); ;             com.DropDownStyle System.Windows.Forms.ComboBoxStyle.DropDownList;             com.FlatStyle System.Windows.Forms.FlatStyle.Flat;             com.Items.AddRange(new object[] {             1,             2,             3,             4});             com.SelectedIndex 0;             this.dataGridView1.Controls.Add(com);             this.dataGridView1.Columns[1].Width com.Width;             com.Location  newSystem.Drawing.Point(((this.dataGridView1.GetCellDisplayRectangle(1, index,true).Right) - (com.Width)), this.dataGridView1.GetCellDisplayRectangle(1, index,true).Y);               Button btn1  new Button();             btn1.Name  btnRun  index.ToString(); ;             btn1.Text  Run;             btn1.Clicknew EventHandler(btn1_Click);               Button btn2  new Button();             btn2.Name  btnRemoveindex.ToString();             btn2.Text  Remove;             btn2.Clicknew EventHandler(btn2_Click);               this.dataGridView1.Controls.Add(btn1);             this.dataGridView1.Controls.Add(btn2);             this.dataGridView1.Columns[3].Width btn1.Width btn2.Width 6;             btn1.Location  newSystem.Drawing.Point(((this.dataGridView1.GetCellDisplayRectangle(3, index,true).Left)), this.dataGridView1.GetCellDisplayRectangle(3, index, true).Y);             btn2.Location  new System.Drawing.Point(((this.dataGridView1.GetCellDisplayRectangle(3, index,true).Right-1) - (btn2.Width)), this.dataGridView1.GetCellDisplayRectangle(3, index,true).Y);         } 3为2中生成的Run按钮和Remove按钮添加单击事件处理程序 public void btn1_Click(object sender, EventArgs e) {             this.richTextBox1.Text  ;             Button btn (Button)(sender);             //这个btn的name是btnRun打头的             string suffix btn.Name.ToString().Substring(6); //后边那个号相当于index的string             Control c findControlByName(suffix);               if (c ! null)             {                 ComboBox com (ComboBox)(c);          //Control ctl1 this.dataGridView1.Controls[Containers i.ToString()];         //ComboBox com (ComboBox)ctl1;  其实这样写更简单点                 for (int i 0; i com.Items.Count; i)                 {                     this.richTextBox1.Text com.Items[i].ToString()  \n;                 }             } }   public void btn2_Click(object sender, EventArgs e)  {         int RowCount  this.dataGridView1.Rows.Count;       Button btn (Button)(sender);             //这个btn的name是btnRemove打头的             string suffix btn.Name.ToString().Substring(9);  //后边那个号相当于index的string             this.dataGridView1.Controls.RemoveByKey(btn.Name);             this.dataGridView1.Controls.RemoveByKey(btnRun  suffix);             this.dataGridView1.Controls.RemoveByKey(Containers  suffix);             int index  Convert.ToInt32(suffix);             this.dataGridView1.Rows.RemoveAt(index);        if (index RowCount - 2)             {                 for (int i index 1; i RowCount - 1; i)                  {                     Control ctl1  this.dataGridView1.Controls[Containers  i.ToString()];                     Control ctl2  this.dataGridView1.Controls[btnRun  i.ToString()];                     Control ctl3  this.dataGridView1.Controls[btnRemove  i.ToString()];                     ComboBox com (ComboBox)ctl1;                     Button btnRun (Button)ctl2;                     Button btnRemove (Button)ctl3;                     //上移一格单元格Height位4Button的Height为23                     com.Location  new System.Drawing.Point(com.Location.X, com.Location.Y - 23);                     btnRun.Location  new System.Drawing.Point(btnRun.Location.X, btnRun.Location.Y - 23);                     btnRemove.Location  new System.Drawing.Point(btnRemove.Location.X, btnRemove.Location.Y - 23);                     //改名字的后缀                     int ji-1;                     com.Name  Containers  j.ToString();                     btnRun.Name  btnRun  j.ToString();                     btnRemove.Name  btnRemove  j.ToString();                 }             } } 4btn1_Click处理中用到的函数findControlByName() public Control findControlByName(string suffix) {             foreach (System.Windows.Forms.Control c in this.dataGridView1.Controls)             {                 if (c.Name  Containers  suffix)                     return c;             }             return null; } 写的比较累赘不知道还有什么更好的方法。请经验人士赐教^_^     转载于:https://www.cnblogs.com/timeover/archive/2010/09/15/1826900.html
http://www.zqtcl.cn/news/305949/

相关文章:

  • 合肥网站建设方案优化写作网站大全
  • 专门提供做ppt小素材的网站网站定位
  • 临沂市建设局兰山区网站wordpress 去除下划线
  • 如何做一张图片的网站关于实验室建设的英文网站
  • 网站建设文本居中代码山东网站推广营销设计
  • 山东桓台建设招投标网站北京建设信息港网站
  • 为什么网站要域名个人养老金制度最新消息
  • 公众号开发是不是网站开发公司网站建设分录
  • 云南省住房建设厅网站代理二级分销系统
  • 四川建设人才培训网站临沂网站制作页面
  • 用vue做网站建设工程合同属于什么合同
  • 赶集的网站怎么做广告投放报价
  • php 家政网站白嫖云服务器
  • 长春网站关键词推广优秀网站建设哪个公司好
  • php实战做网站视频教程站长工具网站测速
  • 当下网站建设常见的网址有哪些
  • 洪雅网站建设事业单位门户网站建设包含内容
  • 外网如何查看局域网建设的网站区块链开发工程师要求
  • 网站首页三张海报做多大怎么做网上直营店网站
  • 网站制作新手教程视频省建设厅网站安全生产标准化
  • 自动建设网站系统阿里云虚拟主机多网站
  • 区块链app排名网站seo其应用
  • 海口网站建设咨询一般网站建设需求有哪些方面
  • 免费网站建设朋友交流模板王网站
  • wordpress不同分类不同广告 文章属于不同分类网站 优化手机版
  • 淮安市建设银行网站首页王也是谁
  • 好用的网站管理系统给wordpress程序提速
  • 网页设计模板的网站网站开发包括哪些
  • 做网站的标准国外html5网站模板
  • 手机网站设计公司立找亿企邦郑州seo网络营销技术