怎样在后台设置imageButton的背景图

imageButton放在Datalist控件里面,而imageButton的背景图为一个连接如下http://wpa.qq.com/pa?p=1:277724043:6... imageButton放在Datalist控件里面,而imageButton的背景图为一个连接如下 http://wpa.qq.com/pa?p=1:277724043:6可是连接里面的2777240243要根据数据库的调用而随时改变要怎么做呢? 展开
 我来答
匿名用户
2013-06-24
展开全部
自定义背景图片.buttonClass
{
border-right: blue 1px solid;
border-top: blue 1px solid;
font-size: 9pt;
background-image: url(button-back.gif);
vertical-align: middle;
border-left: blue 1px solid;
cursor: hand;
color: #000000;
border-bottom: blue 1px solid;
font-family: "宋体";
text-align: center;
}

对button加入这个样式单 想作一个带背景图片的TextBox,给个思路.txt

protected override void OnPaint(PaintEventArgs e)
{
Graphics g=textBox1.CreateGraphics();
Bitmap bt=new Bitmap(yourFile);
g.DrawImage(bt,0,0,textBox1.Width,textBox1.Height);
}

设置TextBox为Transparent,可以这样:
textBox1.BackColor= Color.FromArgb(0, textBox1.BackColor);

我大致做了一个,不过还是无法解决在编辑的时候也显示图片,代码如下:
public class DrawTextBox : System.Windows.Forms.UserControl
{
protected System.Windows.Forms.Label label;
protected System.Windows.Forms.TextBox textBox;
protected bool editing = false;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public DrawTextBox()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
}

public Label Label
{
get{return this.label;}
}

public TextBox TextBox
{
get{return this.textBox;}
}

public bool Editing
{
get{return this.editing;}
set
{
if(this.editing != value)
{
if(!value)
this.EndEditing(value);
else
this.StartEditing();
}
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label = new System.Windows.Forms.Label();
this.textBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label
//
this.label.Dock = System.Windows.Forms.DockStyle.Fill;
this.label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label.Name = "label";
this.label.Size = new Size(88, 20);
this.label.TabIndex = 2;
this.label.Text = "DrawTextBox1";
this.label.Visible = true;
this.label.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Label_MouseUp);
//
// textBox
//
this.textBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox.Name = "textBox";
this.textBox.TabIndex = 2;
this.textBox.Text = "";
this.textBox.Visible = false;
this.textBox.Size = new Size(88, 20);
this.textBox.Location=new Point(0,0);
this.textBox.LostFocus += new System.EventHandler(this.TextBox_LostFocus);
//
// DrawTextBox
//
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label,
this.textBox});
this.Name = "DrawTextBox";
this.ResumeLayout(false);
}
#endregion
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(Control.FromHandle(msg.HWnd) == this.textBox)
{
if(keyData == Keys.Enter)
{
this.EndEditing(true);
return true;
}
else if(keyData == Keys.Escape)
{
this.EndEditing(false);
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}

private void Label_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.StartEditing();
}

protected virtual void StartEditing()
{
this.label.Visible=false;
this.textBox.Modified = false;
this.textBox.Visible = true;
this.textBox.Text = this.label.Text;
this.textBox.Focus();
this.textBox.SelectionStart = 0;
this.textBox.SelectionLength = 0;
this.editing = true;
}

protected virtual void EndEditing(bool save)
{
if(!this.Editing)
return;
if(save && this.textBox.Modified)
{
this.label.Text = this.textBox.Text;
}

this.editing = false;
this.textBox.Text = String.Empty;
this.textBox.Visible = false;
this.label.Visible=true;
}
private void TextBox_LostFocus(object sender, System.EventArgs e)
{
this.EndEditing(true);
}
}

使用如下:
DrawTextBox myDrawText=new DrawTextBox();
myDrawText.Size=new Size(88,20);

myDrawText.Label.Image=Image.FromFile(@yourFile,false);
this.Controls.Add(myDrawText);
博思aippt
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT... 点击进入详情页
本回答由博思aippt提供
匿名用户
2013-06-24
展开全部
datalist控件的属性应该有个行绑定吧,你在那个事件里获取到imagebutton,然后给他赋值就可以了。。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式