文本(标签)未更新(vb.net)

时间:2016-02-09 10:33:28

标签: vb.net label

我正在更新大型数据库中的1个字段。 由于我想看看进展有多远,我想在更新记录时更新我的​​标签。但是,这不起作用:他只在结束时才更新它。

请注意,进度条和更新工作正常,我没有任何错误消息。有什么想法吗?

public class MyFrame extends JFrame {
    public MyFrame() {
        super("Greeting");
        setbounds(200, 200, 200, 150);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("hh");
        JTextArea tx = new JTextArea(10,5);
        String myTime = sdf.format(cal.getTime());
        if (myTime < 12am && myTime > 12pm)
            tx.append("Good Morning");
        }
        if (myTime <12am && myTime > 12pm)
            tx.append("Good Afternoon");
        }
        JPanel pane = new JPanel();
        pane.add(tx);
        add(pane);
        setVisible(true);
    }
    public static void main(String [] args) {
        new MyFrame();
    }
}

1 个答案:

答案 0 :(得分:3)

在设置文本后调用Label.Refresh方法,这将强制标签重绘。您也可以在进度条上调用Refresh方法,以使其顺利运行。

    ...
    ProgressBarTSLabels.Value += 1
    qty += 1
    lblQty.Text = qty & "/" & dt.Rows.Count
    lblQty.Refresh                     '<-- here
    ProgressBarTSLabels.Refresh        '<-- and here
Next