1
、如何在winform中实现显示数据加入html标记
测试代码如下: this.textBox1.Text = "www";
this.webBrowser1.DocumentText = "<b>"+this.textBox1.Text+"</b>";
HtmlElement li1= webBrowser1.Document.All["b"];
if(li1!=null)
{
string content=li1.GetAttribute("content");
this.textBox1.Text = content;
}
this.webBrowser1.DocumentText = "<b>"+this.textBox1.Text+"</b>";
HtmlElement li1= webBrowser1.Document.All["b"];
if(li1!=null)
{
string content=li1.GetAttribute("content");
this.textBox1.Text = content;
}
期待更好的答案。
2
、C#代码错误,不知道错在哪?string sql = "insert into tb_users(uid,pwd,userName) values(@uid,@pwd,@userName)";
SqlParameter p1, p2, p3;
p1 = new SqlParameter("@uid", SqlDbType.VarChar,50);
p2 = new SqlParameter("@pwd", SqlDbType.VarChar,50);
p3 = new SqlParameter("@userName", SqlDbType.VarChar,50);
p1.Value = uid;
p2.Value = pwd;
p3.Value = name;
DataTable myTable = new DataTable();
SqlParameter[] ps = { p1, p2, p3 };
SqlCommand mycomm = new SqlCommand(sql, myconn);
foreach (SqlParameter p in ps)
{
mycomm.Parameters.Add(p);
}
SqlDataAdapter myAdapter = new SqlDataAdapter(sql, myconn);
myAdapter.Fill(myTable);
错误提示为: 必须声明标量变量 "@uid"。
SqlParameter p1, p2, p3;
p1 = new SqlParameter("@uid", SqlDbType.VarChar,50);
p2 = new SqlParameter("@pwd", SqlDbType.VarChar,50);
p3 = new SqlParameter("@userName", SqlDbType.VarChar,50);
p1.Value = uid;
p2.Value = pwd;
p3.Value = name;
DataTable myTable = new DataTable();
SqlParameter[] ps = { p1, p2, p3 };
SqlCommand mycomm = new SqlCommand(sql, myconn);
foreach (SqlParameter p in ps)
{
mycomm.Parameters.Add(p);
}
SqlDataAdapter myAdapter = new SqlDataAdapter(sql, myconn);
myAdapter.Fill(myTable);
错误提示为: 必须声明标量变量 "@uid"。
答案:你少一句
myAdapter.insertCommand = mycomm
myAdapter.insertCommand = mycomm
3
、急急 在线等 c#的一个小编程?
实现在某一textbox里以逗号隔开输入十个0-100之间的整数,若个数不是十个或数字不是整数或不在0-100就提示错误,并重新输入
问题补充:
还有textbox输入的时候第一个不允许为逗号,只能输入数字之后才能写逗号
答案:
下面代码差不多能实现,
while(true)
{
int[] a=new int[10];//保存结果的数组
//将字符串按逗号分割,分割后的各字符串保存到字符串数组s中
string[] input=textbox1.Text.Split(',');
if(input.Length!=10)
{
MessageBox.Show("输入个数不是十个");
continue;
}
int i=0;
for(;i<10;i++)
{
try
{
a[i]=int.Parse(input[i]);//转换为数字
}
catch
{
MessageBox.Show("第"+i+"个输入不是整数");
break;
}
if(a[i]<0||a[i]>100)
{
MessageBox.Show("第"+i+"个数不在0-100");
break;
}
}
if(i==10)
break;//如果十个数都赋值了,就跳出while循环;否则,重新读取
4、C#编程中 如何输出一个数字三角形?
while(true)
{
int[] a=new int[10];//保存结果的数组
//将字符串按逗号分割,分割后的各字符串保存到字符串数组s中
string[] input=textbox1.Text.Split(',');
if(input.Length!=10)
{
MessageBox.Show("输入个数不是十个");
continue;
}
int i=0;
for(;i<10;i++)
{
try
{
a[i]=int.Parse(input[i]);//转换为数字
}
catch
{
MessageBox.Show("第"+i+"个输入不是整数");
break;
}
if(a[i]<0||a[i]>100)
{
MessageBox.Show("第"+i+"个数不在0-100");
break;
}
}
if(i==10)
break;//如果十个数都赋值了,就跳出while循环;否则,重新读取
4、C#编程中 如何输出一个数字三角形?
答案:for(int i=1;i<6;i++)
{
for(int j=1;j<i;j++)
{
console.write(i);
}
console.writeln();
}
{
for(int j=1;j<i;j++)
{
console.write(i);
}
console.writeln();
}
后面会陆陆续续的更新。