您的位置:程序门 -> .net技术 -> vb.net



"new"不能在接口上使用。


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


"new"不能在接口上使用。[已结贴,结贴人:rockyvan]
发表于:2008-01-15 10:24:18 楼主
我在做一個窗體内控件位置大小隨窗體大小而自動調整的工作。
以下是測試程序代碼:
vb.net code
private sub form1_resize(byval sender as object, byval e as system.eventargs) handles me.resize datagridview1.location = new point(me.width *12 / 387), me.height *147 / 414)) datagridview1.size = new point(me.width *363 / 387), me.height *221 / 414)) button1.location = new point(me.width *61 / 387), me.height *36 / 414)) button1.size = new point(me.width *75 / 387), me.height *23 / 414)) button2.location = new point(me.width *232 / 387), me.height *36 / 414)) button2.size = new point(me.width *75 / 387), me.height *23 / 414)) button3.location = new point(me.width *61 / 387), me.height *92 / 414)) button3.size = new point(me.width *75 / 387), me.height *23 / 414)) button4.location = new point(me.width *232 / 387), me.height *92 / 414)) button4.size = new point(me.width *75 / 387), me.height *23 / 414)) end sub

測試通過沒有問題。

以下是實際應用程序裏面的代碼:
vb.net code
private sub frmday_resize(byval sender as object, byval e as system.eventargs) handles me.resize me.rdb1.location = new point(me.width *53 / 800), me.height *11 / 600)) me.rdb1.size = new point(me.width *85 / 800), me.height *19 / 600)) me.lbl1.location = new point(me.width *160 / 800), me.height *36 / 600)) me.lbl1.size = new point(me.width *82 / 800), me.height *15 / 600)) end sub

提示:"new"不能在接口上使用。其中point下面有綠色波浪綫。

爲什麽測試程序沒有問題,到這裡來就有問題了?請高手指點一二。
发表于:2008-01-15 10:30:411楼 得分:10
好像通过上面给出的信息不足以找到问题。

不过有点怀疑,point你是否自己定义成了接口?
发表于:2008-01-15 10:51:062楼 得分:10
按照上面的代码来看,两个代码没什么不同,估计是定义方面可能出错了!
发表于:2008-01-15 10:53:523楼 得分:0
point沒有做任何定義。
point在我程序裏面總共就出現了4次,就是上面的4次。

发表于:2008-01-15 11:00:504楼 得分:0
問題已經解決了,謝謝大家!
vb.net code
me.rdb1.location = new point(me.width *53 / 800), me.height *11 / 600)) '該語句修改如下: me.rdb1.location = new system.drawing.point(me.width *53 / 800), me.height *11 / 600)) '問題即可解決,即point前加上“system.drawing.”。 '經測試通過,沒有問題。
发表于:2008-01-15 11:01:475楼 得分:0
雖然問題自己解決了,分數還是要給。讓兩位費心了。


快速检索

热门点击