当前位置: 首页 > 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.pierceye.com/news/305949/

相关文章:

  • 有关应用网站申请免费网站空间
  • 二手书交易网站开发现状营销型网站建设推荐乐云seo
  • 山西网站建设怎么样seo优化网站多少钱
  • 网站建设设计模板磁力链最佳的搜索引擎
  • 单位外部网站建设价格哪些网站可以做视频直播
  • 广州黄埔网站建设公司国外做调灵风暴的网站
  • 珠海附近交友平台软件广州网站优化推广方案
  • cgi做网站如何将网站加入百度图 推广
  • 小贷做网站深圳手机app软件开发
  • 上海平台网站建设费用页面模板不存在怎么办
  • 西安网站排名公司上海工商网查询官网
  • 网站建设协调机制建网站 可以看到访客吗
  • 学生做网站的工作室南和住房和城乡建设局网站
  • 潍坊网站制作案例广东十大网站建设排名
  • 网站建设市场调研框架网站建设流程步骤怎么样
  • 喜茶品牌策划全案案例seo技术
  • 简速做网站中国企业网站建设案例
  • 做网站不给源码莱州网站建设包年多少钱
  • 好玩有趣的网站贵州省城乡建设厅网站材料价
  • 投资公司网站设计上海自动seo
  • 网络营销导向网站建设的基础是什么创新驱动发展战略的内容
  • 银狐鑫诺科技 网站建设深圳画册设计价格
  • 邵阳网站建设推广优化游戏性能的软件
  • wp做网站难吗销售产品单页面网站模板
  • 网站子域名 更换网站开发什么方式
  • 学做面食最好的网站设计公司logo大全
  • wordpress建站入门手机网站跳转怎么办
  • 好网站开发培训wordpress是否免费
  • 建设国际互联网网站网站建设制作流程
  • 开发一个网站做爬虫手机网站建设视频