当前位置: 代码迷 >> .NET组件控件 >> |M| 怎么给小弟我的自定义控件的换个显示图片啊他在工具栏里是一个齿轮,小弟我想找成一个图片 多谢
  详细解决方案

|M| 怎么给小弟我的自定义控件的换个显示图片啊他在工具栏里是一个齿轮,小弟我想找成一个图片 多谢

热度:3801   发布时间:2013-02-25 00:00:00.0
|M| 如何给我的自定义控件的换个显示图片啊.他在工具栏里是一个齿轮,我想找成一个图片 谢谢
我像aspnetpager一样添加了一个mycontrol.bmp
但不知道怎么把这个图片放到工具栏了
我搜索aspnetpager里面也没有bmp这样的代码

谢谢

------解决方案--------------------------------------------------------
艾,lz问的问题真够细的,很多都是看了也不注意的东西,不知道
------解决方案--------------------------------------------------------
我也想知道呢 很有意思呢
------解决方案--------------------------------------------------------
以下的文章中描述了给自定义控件加上自己定制的图标的具体的方法和详细的步骤,您可以参考:
HOW TO: Add a Custom Toolbox Icon to a Windows Forms Control (Q311315)
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311315

- 微软全球技术中心 VB技术支持

本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。

为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
------解决方案--------------------------------------------------------
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/83a73362edaca03?hl=en&lr=&ie=UTF-8&oe=UTF-8
------解决方案--------------------------------------------------------
eg:

[ToolboxBitmap( "Bs.WebControls.DatePicker.gif ")]

ref:

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.chs/cpref8/html/T_System_Drawing_ToolboxBitmapAttribute.htm

------解决方案--------------------------------------------------------
下面的代码示例演示如何使用 ToolboxBitmapAttribute 类将 stop.bmp 设置为 StopSignControl 的工具箱图标。此示例假设在 c:\ 下存在名为 stop.bmp 的 16 × 16 像素位图。

Visual Basic
<System.Drawing.ToolboxBitmap( "c:\stop.bmp ")> _
Public Class StopSignControl
Inherits System.Windows.Forms.UserControl

Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button

Public Sub New()
MyBase.New()
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button

Me.Label1.Font = New System.Drawing.Font( "Microsoft Sans Serif ", _
12.0F, System.Drawing.FontStyle.Regular, _
System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.Label1.ForeColor = System.Drawing.Color.Red
Me.Label1.Location = New System.Drawing.Point(24, 56)
Me.Label1.Name = "Label1 "
Me.Label1.TabIndex = 0
Me.Label1.Text = "Stop! "
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

Me.Button1.Enabled = False
Me.Button1.Location = New System.Drawing.Point(56, 88)
Me.Button1.Name = "Button1 "
Me.Button1.Size = New System.Drawing.Size(40, 32)
Me.Button1.TabIndex = 1
Me.Button1.Text = "stop "

Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Name = "StopSignControl "

End Sub

Private Sub StopSignControl_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.MouseEnter

Label1.Text.ToUpper()
Label1.Font = New System.Drawing.Font(Label1.Font.FontFamily, _
14.0F, System.Drawing.FontStyle.Bold)
Button1.Enabled = True
End Sub

Private Sub StopSignControl_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.MouseLeave

Label1.Text.ToLower()
  相关解决方案