填充由id过滤的数据网格内的组合框

编程入门 行业动态 更新时间:2024-10-28 06:36:40
本文介绍了填充由id过滤的数据网格内的组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以帮我吗?我的数据网格中有一个组合框,我需要在其中填充数据..我的问题是关于我的变量模式..如果mode = 1应该在组合框内但是如果不是(例如mode = 2或3或4)那么组合框内应该没有任何东西。我的代码无效。无论模式是1还是2还是其他数字我的组合框仍在填充数据。 PS:模式和总数的值来自另一个查询。请。不要困惑。 :)

Can someone help me with this?? there is a combobox inside my datagrid and i need to populate data in it.. my problem is about my variable mode.. if mode = 1 there should be inside the combobox but if its not (for example mode = 2 or 3 or 4) then there should be nothing inside the combobox. my code is not working. whether the mode is 1 or 2 or other number my combobox is still populating data. PS: values of mode and total are from another query. pls. dont be confused. :)

Dim cmbDeb As New DataGridViewComboBoxColumn cmbDeb.HeaderText = "Debit" ReDim mode(0 To total) For i = 0 To total mode(i) = dt.Rows(i)(0) If mode(i) = 1 Then SqlStr = "SELECT accountName FROM mst_Account" dt = qry.ExecuteSql(SqlStr) cmbDeb.Items.Add(dt.Rows(0).Item(0)) Else 'nothing must be inside the combobox End If Next Me.dgJP.Columns.Add(cmbDeb)

推荐答案

为什么要使用for循环?问题是因为for循环。 当i = 0的值时,你的cmbDeb将为空。当i = 1时 ,你的cmbDeb将被填满。 当i = 2的值时,你的cmbDeb将包含值因为它已经填满而值= 1 当i的值= 3,你的cmbDeb将包含值,因为它已经填满,而值= 1 等等。 和最后你向dgJP添加列。因此,当值为1时,cmbDeb的值将被填满。 why do you use for loop ? Issue is because of for loop. when value of i = 0, your cmbDeb will be empty. when value of i = 1, your cmbDeb will be filled up. when value of i = 2, your cmbDeb will contain values because it is already filled up while value = 1 when value of i = 3, your cmbDeb will contain values because it is already filled up while value = 1 and so on. and at the end you add columns to dgJP. So it will will the value of cmbDeb which is already filled up when value was 1.

更多推荐

填充由id过滤的数据网格内的组合框

本文发布于:2023-10-12 03:01:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483557.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   网格   数据   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!