简体   繁体   中英

How to stop label from adding results each time a button is clicked

I am working on a project for school. I have to create and SQL statement and then use a while loop to input information into a label. Every thing is working correctly except when you search for a new item, the label still displays the result from the last search. Code Picture Second Result Picture Any way to fix this?

在开始循环之前,您应该清除标签的文本。

you need to clear the label text first then show the result on it. label1.text="";

You need to clear before start a new loop. Try this:

Nameofyourlabel.Text = "";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM