繁体   English   中英

我如何在datagridview的复选框上添加if语句?

[英]how can i add a if statements on the checkbox in the datagridview?

谁能告诉我如何在数据网格视图的复选框上添加if语句。 因为我只是vb.net的初学者,我对代码并不那么熟悉,现在我正在为每个学科的学生建立出勤系统。所以我如何添加一个条件来知道学生是否单击该复选框后,是存在还是不存在?

您可以使用row.FindControl之类的(c#)查找控件

     foreach (GridViewRow row in gvStudents.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
     CheckBox chkAttendance = row.FindControl("chkAttendence") as CheckBox;
     string attendanceStatus = chkAttendance.Checked ? "Present" : "Absent";
     ...


    }
}

您可以在此链接中找到类似的示例: AttendenceGridView

暂无
暂无

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

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