简体   繁体   English

VB .net:如何将值放在复选框上(数据库:MS Access)

[英]VB .net: How to put a value on a checkbox (databese: MS Access)

I just need a little help for my homework. 我只需要一点帮助就可以做作业。 I did my best think about the logic but it's too late. 我尽了最大的努力思考逻辑,但为时已晚。 So basically, this is what I need to do : 所以基本上,这是我需要做的:

If I'll check the checkbox 1 it will automatically input "100" on the second column of my datagridview and also if I'll check checkbox 2 it will also input "50" on my 3rd column. 如果我选中复选框1,它将在我的datagridview的第二列中自动输入“ 100”,并且如果我选中复选框2,它还将在我的第三列中输入“ 50”。



[ ] Fee1 (checkbox1) = $100 [] Fee1 (checkbox1)= $ 100
[ ] Fee2 (checkbox2) = $50 [] Fee2 (checkbox2)= $ 50


The output should look like this: 输出应如下所示:

StudentFeeTableGridView StudentFeeTableGridView

Name| 名称| Fee 1| 费用1 | Fee 2 费用2
Jack | 杰克| 0 | 0 | 50 50
Jill | 吉尔| 100 | 100 | 0 0
John | 约翰| 100 | 100 | 0 0
Jose | 何塞| 0 | 0 | 50 50


Thank you so much guys for helping! 非常感谢你们的帮助! I owe you. 我欠你。

Set DataGridView.SelectionMode=FullRowSelect and use CheckedChanged event. 设置DataGridView.SelectionMode=FullRowSelect并使用CheckedChanged事件。 With code below, values will be inserted to cells in selected row: 使用下面的代码,值将插入到选定行中的单元格:

  • For 1 checkbox: 对于1个复选框:

If (Fee1.checked=True) Then dataGridView1.CurrentRow.Cells("Fee1").Value="100"

  • For 2 checkbox: 对于2复选框:

If (Fee2.checked=True) Then dataGridView1.CurrentRow.Cells("Fee2").Value="50"

Note : .Cells("Fee1") and .Cells("Fee2") must be valid column name in DataGridView. 注意.Cells("Fee1").Cells("Fee2")在DataGridView中必须是有效的列名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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