这个地方缺少参数才报错的,删除要定义这么个删除法,如,删除后右边的单元格左移来补充。
创新互联公司总部坐落于成都市区,致力网站建设服务有成都网站制作、做网站、网络营销策划、网页设计、网站维护、公众号搭建、微信小程序定制开发、软件开发等为企业提供一整套的信息化建设解决方案。创造真正意义上的网站建设,为互联网品牌在互动行销领域创造价值而不懈努力!
因为你在删除的过程中,控件数量改变,导致循环次数不准确,所以才会不完全删除控件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace WindowsApplication14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
setLabel(5);
}
private void setLabel(int num)
{
for (int i = 0; i num; i++)
{
Label testLbl = new Label();
testLbl.Text = i.ToString();
this.Controls.Add(testLbl);
testLbl.Top = i * 50;
testLbl.Left = 10;
}
}
private void button1_Click(object sender, EventArgs e)
{
clearLabel(this);
}
private void clearLabel(Control container)
{
for (int i = container.Controls.Count; i 0;i-- )
{
Label lbl = container.Controls[i-1] as Label;
container.Controls.Remove(lbl);
}
}
private void button2_Click(object sender, EventArgs e)
{
setLabel(5);
}
}
}
你是要把连续多个空格,变换成只需要一个空格,那么:
do while Instr(tStr," ")0
tStr = Replace(tStr, " ", " ") '用一个空格,替换2个空格
loop
要用GreateGrahpics函数,比如要向 Panel1,填充颜色:
Dim g As Graphic=Panel1.CreateGraphics
Dim b as New Brush(Color.Blue)
g.FillRectangle(b,Panel1)
写的比较粗,意思就是这样的,你可以边看帮助边细细完成