VB.Net Image未在运行时显示

时间:2012-02-09 05:42:42

标签: vb.net image icons runtime

按钮图像和图标未在运行时显示

按钮图片

Me.wibtnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
Me.wibtnAdd.DisabledImagesGrayScale = False
Me.wibtnAdd.Enabled = False
Me.wibtnAdd.Image = CType(resources.GetObject("wibtnAdd.Image"), System.Drawing.Image)
Me.wibtnAdd.ImageFixedSize = New System.Drawing.Size(24, 24)
Me.wibtnAdd.ImagePosition = DevComponents.DotNetBar.eImagePosition.Top
Me.wibtnAdd.Location = New System.Drawing.Point(53, 302)
Me.wibtnAdd.Name = "wibtnAdd"
Me.wibtnAdd.Shape = New DevComponents.DotNetBar.RoundRectangleShapeDescriptor(2)
Me.wibtnAdd.Size = New System.Drawing.Size(61, 52)
Me.wibtnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled
Me.wibtnAdd.TabIndex = 8
Me.wibtnAdd.Text = "Add"

表单图标

  Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)

1 个答案:

答案 0 :(得分:0)

让你的代码更清晰:1)摆脱'我'                                2)使用'With'子句 (我编辑)

问题似乎在于您对资源的访问:您确定吗? 你有一个名为“wibtnAdd.Image”的资源?看起来很'奇怪' 它与您的对象/属性具有相同的名称...检查您的 wibtnAdd.Image,它可能没什么。你的Icon也是如此。

顺便问一下为什么不在xaml中这样做?它会更具可读性 并且您可以在看到结果的同时编辑所有内容。