Home>Article>Computer Tutorials> How to add icons to custom component controls in C language
Just add the ToolboxBitmapAttribute to the class of your control or component
As shown below (I only tested it on the windows form control, I think it should be possible for web form)
using System;
using System.Windows.Forms;
using System.Drawing;
namespace Zxd
{
[ToolboxBitmap("open.bmp")]//Note: The parameter is your bitmap path. In my experiment, it is in the same directory as the generated Test.Dll file
public class Test:System.Windows.Forms.UserControl//Control
{
Omit
}
}
checkChaged event
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
this.Image1.ImageUrl = "iamges/1.jpg";
}
public void checkRadioButtonChecked()
//Put it in if(!ispostback) of pageLoad
{
if (RadioButton1.Checked)
{
this.Image1.ImageUrl = "iamges/1.jpg";
}
else
{
this.Image1.ImageUrl = "iamges/2.jpg";
}
}
1. There may be help in the team here
2. Edit the corresponding resource file (bmp format), then:
//Set background image
CDC MemDC;
CBitmap m_Bitmap1;
m_Bitmap1.LoadBitmap(IDB_BKGROUND);
MemDC.CreateCompatibleDC(NULL);
MemDC.SelectObject(&m_Bitmap1);
pDC->StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),&MemDC,0,0,48,48,SRCCOPY);
m_Bitmap1.DeleteObject();
MemDC.DeleteDC();
The above is the detailed content of How to add icons to custom component controls in C language. For more information, please follow other related articles on the PHP Chinese website!