我需要C#中的功能,例如滚动图像。
图像应从数据库调用,然后单击下一步。应显示接下来的4张图像。我试过它:
Frame f = new Frame (str); //Use this to open the JFrame
f.setVisible(true);
class Frame extends JFrame {
private String str;
public Frame (String str) {
this.str = str;
this.add(new JLabel(str, JLabel.CENTER));
}
public String getString() {
return this.str;
}
}
但是当调用这些功能时,初始值将出现在第一个。
如何覆盖初始值?
答案 0 :(得分:0)
这是一个可以帮助您入门的代码段。
int j = 1, k = 4;
protected void Page_Load(object sender, EventArgs e)
{
//check if the viewstate exists, if not store default value of j
if (ViewState["recomended"] == null)
{
ViewState["recomended"] = j;
}
else
{
//convert the viewstate back to an int
j = Convert.ToInt32(ViewState["recomended"]);
//pretty obvious what this does...
k = j + 3;
}
}
private void recomended()
{
//save the new value of j in the viewstate
ViewState["recomended"] = j;
//visualize the result
Label1.Text = j + " " + k;
}
protected void btnleft_Click(object sender, EventArgs e)
{
j = j - 4;
k = k - 4;
recomended();
}
protected void btnright_Click(object sender, EventArgs e)
{
j = j + 4;
k = k + 4;
recomended();
}