如何停止反复添加Combobox [英] How Can I Stop Repeatedly Adding In Combobox

查看:78
本文介绍了如何停止反复添加Combobox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim MyTableCount As Integer = ds.Tables.Count
        For Each row As DataRow In ds.Tables(0).Rows
            cmbToDatabase.Properties.Items.Add(row.Item("Name"))
        Next row



它填充组合框三次。如何只填充一次


it fills the combobox thrice.How i fill only one time

推荐答案

在组合框中添加项目之前,请在下面的代码中写下此代码,它将清除所有组合框属性项目



Write this below code before you add the items in combobox, it'll clear all the combobox property items

cmbToDatabase.Properties.Items.Clear()
Dim MyTableCount As Integer = ds.Tables.Count
        For Each row As DataRow In ds.Tables(0).Rows
            cmbToDatabase.Properties.Items.Add(row.Item("Name"))
        Next row


这些问题很容易解决。在调试器下执行。将断点放在添加项目的代码行中,并在第二次发生时捕获它们。在调试器中,查看调用堆栈窗口。它会显示所有电话到达此行的位置。



-SA
Such problems are easy to solve. Do it under the debugger. Put a breakpoint the the line of code where the items are added and catch them moment when it happens for the second time. In the debugger, look at "Call stack" window. It will show you where all the calls get you to this line.

—SA


这篇关于如何停止反复添加Combobox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆