Winform给图片控件赋值“无效参数”

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zh275589797/article/details/51701357
循环给图片控件赋值时,不定时遇到“无效参数”的异常,加try catch块也没捕获到,程序直接崩溃,后来调整了下局部代码顺序,程序目前没再抛异常,搞什么鬼:-_-

<pre name="code" class="csharp">
/*
picMain是PictureBox控件 
执行顺序1,2,3目前不报参数不正确的异常了;
如果执行顺序修改为2,1,3,则不定时抛出“无效参数”的异常信息,相当诡异。
*/

//1

Bitmap camBitmap=dosomething();

//2

if (picMain.Image != null)
picMain.Image.Dispose();


//3

picMain.Image = camBitmap;





展开阅读全文

数据图片参数无效

11-19

[code=VB.NET]rnrnrnImports System.Data.OleDbrnImports System.IOrnrnPublic Class Form1rn Dim topics As New DataSetrn Dim dbfconn As OleDb.OleDbConnection = New OleDb.OleDbConnectionrnrn Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loadrnrn End Subrnrn Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clickrn Dim path, FileName As Stringrn Me.OpenFileDialog1.Title = "选择dbf文件"rn Me.OpenFileDialog1.Filter = "dbf文件|*.dbf"rn If Me.OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Thenrn path = System.IO.Path.GetDirectoryName(OpenFileDialog1.FileName)rn FileName = System.IO.Path.GetFileName(OpenFileDialog1.FileName)rn FileName = Microsoft.VisualBasic.Left(FileName.ToUpper, FileName.Length - 4)rn ' Dim conn As String = "Provider=VFPOLEDB.1;Data Source=" & path & ";Mode=ReadWrite;Collating Sequence=MACHINE;Null=Yes;Deleted=Yes;"rn Dim conn As String = "Provider=VFPOLEDB.1;Data Source=" & path & "; Password='';Collating Sequence=MACHINE;"rnrn Dim dbfconn As OleDb.OleDbConnection = New OleDb.OleDbConnectionrn dbfconn.ConnectionString = connrn Dim cmd As String = "select 姓名,身份证号码,照片 from " & FileNamern Dim adapter As New OleDbDataAdapter(cmd, dbfconn)rn adapter.Fill(topics, "a")rn Me.DataGridView1.DataSource = topicsrn Me.DataGridView1.DataMember = "a"rn Me.DataGridView1.Refresh()rn End Ifrn End Subrnrn Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clickrn Dim ImgByt() As Bytern Dim ImgMS As IO.MemoryStreamrn ImgByt = CType(topics.Tables("a").Rows(2).Item("照片"), Byte())rn ImgMS = New IO.MemoryStream(ImgByt)rn PictureBox1.Image = Image.FromStream(ImgMS)rn End SubrnEnd Classrnrnrnrn[/code]rnrnrnrn提示PictureBox1.Image = Image.FromStream(ImgMS)中的参数无效(ImgMS)rnrn 论坛

web控件开发按钮事件给labelLiteral.text赋值无效

01-31

[code=C#]rn public class ServerControl1 : CompositeControlrn rn [Bindable(true)]rn [Category("Appearance")]rn [DefaultValue("")]rn [Localizable(true)]rn public string sqlrn rn getrn rn String s = (String)ViewState["sql"];rn return s;rn rnrn setrn rn ViewState["sql"] = value;rn rn rn rn [Bindable(true)]rn [Category("Appearance")]rn [Localizable(true)]rn [DefaultValue(1)]rn public int pageCurrentrn rn getrn rn int s = (int)ViewState["pageCurrent"];rn return s;rn rnrn setrn rn ViewState["pageCurrent"] = value;rn rn rnrn int pageSize; //每页显示行数 rn int nMax; //总记录数 rn int pageCount; //总页数=总记录数/每页显示行数 rn //int pageCurrent; //当前页号 rn int nCurrent; //当前记录行rnrn DataSet ds = new DataSet();rn DataTable dt;rn SqlDataAdapter sda;rnrn Literal mTab;rn rnrn Label CountLab;rn Button Fpage;rn Button Ppage;rn Label CurrLab;rn Button Npage;rn Button Lpage;rn Panel pc;rnrn rnrn protected override void CreateChildControls()rn rn this.Controls.Clear();rnrn mTab = new Literal();rnrn CountLab = new Label();rn Fpage = new Button();rn Ppage = new Button();rn CurrLab = new Label();rn Npage = new Button();rn Lpage = new Button();rn pc = new Panel();rnrn mTab.ID = this.ID + "mTab";rn CountLab.ID = this.ID + "CountLab";rn Fpage.ID = this.ID + "Fpage";rn Ppage.ID = this.ID + "Ppage";rn CurrLab.ID = this.ID + "CurrLab";rn Npage.ID = this.ID + "Npage";rn Lpage.ID = this.ID + "Lpage";rn pc.ID = this.ID + "pc";rnrn Fpage.Text = "首页";rn Ppage.Text = "上页";rn Npage.Text = "下页";rn Lpage.Text = "末页";rnrn Fpage.Click += new EventHandler(Fpage_Click);rn Npage.Click += new EventHandler(Npage_Click);rnrn pc.Controls.Add(CountLab);rn pc.Controls.Add(Fpage);rn pc.Controls.Add(Ppage);rn pc.Controls.Add(CurrLab);rn pc.Controls.Add(Npage);rn pc.Controls.Add(Lpage);rnrn this.Controls.Add(mTab);rn this.Controls.Add(pc);rnrn this.ChildControlsCreated = true;rnrn rnrn protected override void RecreateChildControls()rn rn if (this.ChildControlsCreated == false)rn rn base.RecreateChildControls();rn rn rnrn protected override void RenderContents(HtmlTextWriter output)rn rn pageSize = 15; //每页显示行数 rn nMax = 0; //总记录数 rn pageCount = 0; //总页数=总记录数/每页显示行数 rn pageCurrent = 1; //当前页号 rn nCurrent = 0; //当前记录行rnrn dt = getDt();rnrn //this.ViewState[this.ID + "dt"] = dt;//保存datatablernrn mTab.Text = BindView(pageCurrent);rn mTab.RenderControl(output);rn pc.RenderControl(output);rn rn void Fpage_Click(object sender, EventArgs e)rn rn //throw new NotImplementedException();rn mTab.Text = "";rn Fpage.Text = pageCurrent.ToString();rn Npage.Text = pageCurrent.ToString();rn rn[/code]rn Fpage.Text = pageCurrent.ToString();rn Npage.Text = pageCurrent.ToString();rn上面的给按钮text赋值成功改变rn mTab.Text = "";这个没有改变,还是原来的值,rn 论坛

错误的参数号或是无效的属性赋值

04-25

实现的是50行数字 每行32个 按照排列选择30组 统计每组中多出现的数字rnhttp://topic.csdn.net/u/20080423/17/73ce31e3-4cd7-4e39-a16a-9e1f1f184c1a.html原帖地址rnrn相关代码:rnDim strIntsz(50) As String '存放输入的10行数据rnDim intData(50, 32) As Double '存放每行分离出来的数字rnDim strOut As Stringrnrn'此函数用于比较任意三十组 数组中有没有相同数,有输出相同的数,没有输出“NO Find!”rnPrivate Function strBJ(ByRef a() As Double, ByRef b() As Double, ByRef c1() As Double, ByRef c2() As Double, ByRef c3() As Double, ByRef c4() As Double, ByRef c5() As Double, ByRef c6() As Double, ByRef c7() As Double, ByRef c8() As Double, ByRef c9() As Double, ByRef c10() As Double, ByRef c11() As Double, ByRef c12() As Double, ByRef c13() As Double, ByRef c14() As Double, ByRef c15() As Double, ByRef c16() As Double, ByRef c17() As Double, ByRef c18() As Double, ByRef c19() As Double, ByRef c20() As Double, ByRef c21() As Double, ByRef c22() As Double, ByRef c23() As Double, ByRef c25() As Double, ByRef c26() As Double, ByRef c27() As Double, ByRef c28() As Double) As StringrnDim smtp(50) As DoublernDim intCont As IntegerrnDim str As StringrnintCont = 0rnFor i = 1 To 60rnFor j = 1 To 60rnIf a(i) = b(j) ThenrnintCont = intCont + 1rnsmtp(intCont) = a(i)rnEnd IfrnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c1(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c2(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c3(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c4(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c5(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c6(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c7(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c8(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c9(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c10(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c11(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c12(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c13(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c14(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c15(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c16(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c17(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c18(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c19(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c20(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c21(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c22(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c23(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c24(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c25(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c26(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c27(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnFor i = 1 To intContrnFor j = 1 To 60rnIf smtp(i) = c28(j) Then str = str + CStr(smtp(i)) + " "rnNext jrnNext irnrnrnIf str = "" ThenrnstrBJ = "No Find!"rnElsernstrBJ = strrnEnd IfrnEnd FunctionrnrnPrivate Sub Command2_Click() 'rn' ReDim intData(10, 10) As DoublernDim X1(32) As DoublernDim X2(32) As DoublernDim X3(32) As DoublernDim X4(32) As DoublernDim X5(32) As DoublernDim X6(32) As DoublernDim X7(32) As DoublernDim X8(32) As DoublernDim X9(32) As DoublernDim X10(32) As DoublernDim X11(32) As DoublernDim X12(32) As DoublernDim X13(32) As DoublernDim X14(32) As DoublernDim X15(32) As DoublernDim X16(32) As DoublernDim X17(32) As DoublernDim X18(32) As DoublernDim X19(32) As DoublernDim X29(32) As DoublernDim X20(32) As DoublernDim X21(32) As DoublernDim X22(32) As DoublernDim X23(32) As DoublernDim X24(32) As DoublernDim X25(32) As DoublernDim X26(32) As DoublernDim X27(32) As DoublernDim X28(32) As DoublernDim X30(32) As DoublernDim n As IntegerrnDim v As Variantrn'下面程序将10行数字分离并存入 二维数组中rnFor i = 1 To 50rnv = Split(strIntsz(i), " ")rnFor j = 1 To (UBound(v) + 1)rnintData(i, j) = CStr(v(j - 1))rnDebug.Print v(j - 1)rnNext jrnNext irnn = 1rnDo While n <= 22 '选择任意三十组组合rnFor i = n + 28 To 50rnFor j = 1 To 50rnrnX1(j) = intData(1, j)rnX2(j) = intData(n, j)rnX3(j) = intData(n + 1, j)rnX4(j) = intData(n + 2, j)rnX5(j) = intData(n + 3, j)rnX6(j) = intData(n + 4, j)rnX7(j) = intData(n + 5, j)rnX9(j) = intData(n + 6, j)rnX10(j) = intData(n + 7, j)rnX11(j) = intData(n + 8, j)rnX12(j) = intData(n + 9, j)rnX13(j) = intData(n + 10, j)rnX14(j) = intData(n + 11, j)rnX15(j) = intData(n + 12, j)rnX16(j) = intData(n + 13, j)rnX17(j) = intData(n + 14, j)rnX18(j) = intData(n + 15, j)rnX19(j) = intData(n + 16, j)rnX20(j) = intData(n + 17, j)rnX21(j) = intData(n + 18, j)rnX22(j) = intData(n + 19, j)rnX23(j) = intData(n + 20, j)rnX24(j) = intData(n + 21, j)rnX25(j) = intData(n + 22, j)rnX26(j) = intData(n + 23, j)rnX27(j) = intData(n + 24, j)rnX28(j) = intData(n + 25, j)rnX29(j) = intData(n + 26, j)rnX30(j) = intData(n + 27, j)rnNext jrnstrOut = strBJ(X1(), X2(), X3(), X4(), X5(), X6(), X7(), X8(), X9(), X10(), X19(), X18(), X17(), X16(), X15(), X14(), X13(), X12(), X11(), X20(), X21(), X22(), X23(), X24(), X25(), X26(), X27(), X28(), X29(), X30())rnPrint CStr(n) & "&" & CStr(n + 1) & "&"; CStr(i) & ": " & strOutrnstrOut = ""rnNext irnn = n + 1rnLooprnEnd Subrnrn在导入 数组后执行COMMAND2时候rn错误在这里rnstrOut = strBJ(X1(), X2(), X3(), X4(), X5(), X6(), X7(), X8(), X9(), X10(), X19(), X18(), X17(), X16(), X15(), X14(), X13(), X12(), X11(), X20(), X21(), X22(), X23(), X24(), X25(), X26(), X27(), X28(), X29(), X30()) rn提示 rn错误的参数号或是无效的属性赋值rnrn是怎么回事呢 论坛

没有更多推荐了,返回首页