473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# Is Checkbox Checked In DataGridView

ilearneditonline
130 Expert 100+
I am working a utility to build some tables in a proprietary database that we use. I have put a quote in to point out the problem. If that checkbox is checked, then i want to set the value of the pk string to PRIMARY KEY and the fieldname.

I have tried
Expand|Select|Wrap|Line Numbers
  1. if (dg[5, i] == checked)
Expand|Select|Wrap|Line Numbers
  1. if (dg[5, i])
but so far I have gotten is
Error 1 Operator '==' cannot be applied to operands of type 'object' and 'bool'
Expand|Select|Wrap|Line Numbers
  1. public string BuildCreateTableString(System.Windows.Forms.DataGridView dg, string tablename)
  2.         {
  3.             StringBuilder sb = new StringBuilder("");
  4.             string pk = "";
  5.             sb.Append("CREATE TABLE " + tablename + "(");
  6.             int i = 0; // counter for datagrid rows
  7.             while (i < dg.Rows.Count - 1){
  8.                 sb.AppendLine("");
  9.                 if (i > 0)
  10.                     sb.Append(",");
  11.                 sb.Append(dg[0, i].Value);
  12.                 sb.AppendFormat("\t\t");
  13.                 sb.Append(dg[1, i].Value);
  14.                 // culprit
  15.                 if (dg[5, i] == true)
  16.                     pk += "Primary Key " + dg[0, i];
  17.                 i++;
  18.             }
  19.             sb.Append(pk);
  20.             return sb.ToString();
  21.         }
Jul 11 '07 #1
0 1261

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: michael schindler | last post by:
hi there i have tried do use the new DataGridView of the Framework 2.0. i use the new DataGridViewCheckBoxColumn Somehow i don't know how to read if a checkbox is checked or not. For example in...
6
by: Bill | last post by:
I have an unbound DataGridView with a DataGridViewCheckBoxColumn as column 2(configured in the designer). How would I programatically set the checkbox state in, say, row 3 column 2? I need to do...
8
by: Mike | last post by:
Hi all, I have a DataGridViewCheckBoxColumn as one of my columns in a DataGridView. I want this checkbox to only be checked, but not unchecked - it's used by the user to audit that they have...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
3
by: sankarpulivarthi | last post by:
Hi i have a checkbox in first datagridview . when it is checked it should get that row values.and iam trying to display that checked row values in a second datagridview after clicking a button....
2
by: mrstrong | last post by:
Gday, Why would all my checkboxes inside a datagridview stop working (ie checked state not updating when user clicks) when the datagridview's editmode property is changed to "EditOnEnter"? It...
1
by: zacks | last post by:
Using VS 2005. I have an app that has a DataGridView control. This control has two columns, the first column is a standard TextBox, and the second column is a CheckBox. I am having difficulty...
1
by: QuickBooksDev | last post by:
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status I would like to use the DataGridView Checkbox like a normal checkbox. When someone clicks on it I would expect that I...
2
by: sajjeelhassan | last post by:
hi can any one tell i found a problem ...while during work on datagridview checkbox is in the 2nd column of the datagridview having header "REGISTER" and a textbox in the 1st column of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.