简体   繁体   English

我如何在代码中检查是否选中了我的 DataGridView 复选框。 c# 视觉工作室 Windows 窗体

[英]How do I in code check that my DataGridView checkbox is selected. c# visual studio Windows form

I am wondering if there is a way to check that the last row is selected as this is a "Delivery / order system".我想知道是否有办法检查是否选择了最后一行,因为这是一个“送货/订购系统”。 I want to know if its selected so that I can make it output this row into my other table which is the cart.我想知道它是否被选中,以便我可以将这一行 output 放入我的另一个表(即购物车)中。 DataGrid is called dgvForSale. DataGrid 称为 dgvForSale。 提供一些上下文的网格图像

I have just tried some of the things I have found on stack overflow but do not fully understand them to change it so that it will work on mine.我刚刚尝试了一些我在堆栈溢出上发现的东西,但没有完全理解它们来改变它,以便它可以在我的上工作。

unfortunately you didnt post any kind of code so its very hard to say.不幸的是你没有发布任何类型的代码所以很难说。 Please next time post the code.请下次发布代码。

But maybe this can be a solution fpr your problem.但也许这可以解决您的问题。 You have to bin de checkbox with de 'isChecked' variable.您必须使用 de 'isChecked' 变量绑定 de checkbox。

<CheckBox IsChecked="IsChecked" />

private bool _isChecked;
public bool IsChecked
{
    get { return _isChecked; }
    set { _isChecked = value; }
}

so i think now you can check if the checkbox is true or false.所以我认为现在您可以检查复选框是对还是错。 If this isnt a good solution for you please post your code, too.如果这对您来说不是一个好的解决方案,请也发布您的代码。

暂无
暂无

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

相关问题 初始化 C# Visual Studio Windows 窗体应用程序后,如何更改窗体的视觉效果? - How do I change the visual of a form after it has Initialized C# Visual Studio Windows Form App? 如何在datagridview c#中检查是否已选中多个复选框 - How to check if multiple checkbox is selected or not in datagridview c# 如何在我的 Visual Studio Code c# 项目中设置默认的 c# 文件? - How do I set the default c# file in my Visual Studio Code c# Project? 当我在C#Windows应用程序中选中复选框时,如何更改datagridview行中的颜色? - how to change the color in datagridview row when i check the checkbox in C# windows applications? 如何将控制台应用程序中的变量值传递给 C# 中的 windows 表单应用程序(Visual Studio) - How do i pass a variable value from Console application to windows form application in C# (visual studio) 如何在 Visual Studio C# 中创建表单实例? - How do I create an instance of a form in Visual Studio C#? 如何使 Visual Studio 中 Unity 的 C# 代码看起来/像教程中那样工作(图片) - How do I make my C# code for Unity in Visual Studio look/work like in the tutorial (picture) C#Visual Studio:如何使用LINQ使用DataGridView从Edit更新数据库? - C# Visual Studio: How do I update a DB from Edit with DataGridView using LINQ? 如何缩短 c# windows 窗体中的重复代码? - How do I shorten repeating code in c# windows form? 如何在C#WIndows表单中附加视频? - How do I attached a video in my C# WIndows Form?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM