473,320 Members | 1,865 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,320 software developers and data experts.

windows form datagrid boolcolumn

Hi there,

I need to get the checked box unchecked in the boolcolumn by default,
when the datagrid is loaded. Is there anyway to do it?

I have removed the dbnull state from boolcolumn by setting the
allownull property false.

Thanks,
Chandru

Nov 16 '05 #1
4 1652
If your column is bound, then it would get the checked state from the
backing data table. You can add a bit/boolean column to your backing table
and set all the values to false and then bind this to the datagridcolumn. If
this does not work, you can create your own Column style by deriving from
DataGridColumnStyle or DataGridBoolColumn and override the Paint() and
Edit() implementation to handle your check box.

Hope this helps
Shuvro

"chandru" <ch************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi there,

I need to get the checked box unchecked in the boolcolumn by default,
when the datagrid is loaded. Is there anyway to do it?

I have removed the dbnull state from boolcolumn by setting the
allownull property false.

Thanks,
Chandru

Nov 16 '05 #2
Chandru,

In addition to Shuvro's first method, which can be in my opinion the best
when you want to keep it separated.

Can you as well loop through your datasource and set the used column to
"false".
When you do that will the rowstate be changed, therefore when you don't want
that, you can set that back to unchanged using the datatable.acceptchanges.

Rembember that a change of the checkbox will than set the rowstate to
changed even when it was in advance in the state it was.

I hope this helps?

Cor
Nov 16 '05 #3
Thanks Shuvro and Cor. I got it to work!

Nov 16 '05 #4
Hello,

I have the same kind of problem than chandru.

However it is slightly different. I retrieve an XML file that I put in a
dataset. I want to add a column in this dataset to have later a column with
checkboxes.

I do this:
--
private void InitializeDataSet()
{ this.datasetTestCases.automated_test_case.Columns. Add("selectTest",
typeof(bool));
}
--
If I had "false" as third argument, I have my checkboxes unchecked, however,
during runtime, I get the following error when I try to modify the value:

Column selectTest is read only, do you want to correct the value?

When I do not put this third argument, I can check/unckeck the checkboxes.
But, when my form is loaded, all the column has the checkboxes checked with
greybackground (like having null value) but I disabled this null value.

I have tried to do a loop to change the value of this dataset, but nothing
happen.

Here is the code for a button to change the value of the dataset.

--
private void memberButtonSelectAll(object sender, System.EventArgs e)
{
for (int i = 0; i<this.datasetTestCases.automated_test_case.Rows.C ount; i++)
{
this.datasetTestCases.automated_test_case[i][0] = true;
}
this.dataGrid.Refresh();
}
--

Here is my setting for my datagridboolcolumn:

--
//
// myDataGridBoolColumnSelect
//
this.myDataGridBoolColumnSelect.AllowNull = false;
this.myDataGridBoolColumnSelect.FalseValue = false;
this.myDataGridBoolColumnSelect.MappingName = "selectTest";
this.myDataGridBoolColumnSelect.NullValue = true;
this.myDataGridBoolColumnSelect.TrueValue = true;
this.myDataGridBoolColumnSelect.Width = 30;
this.myDataGridBoolColumnSelect.NullText = true.ToString();
--

Thank you.
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wayne | last post by:
I have a datagrid on my windows form, it needs to be read only and when a user selects a row, I want the whole row to be selected. How would I go about doing this? -- Thanks Wayne Sepega...
5
by: jdipalmajr | last post by:
I have a table which is being displayed in a DataGrid. One of the columns is a boolean. When I began my development, I wasn't using styles to control column formats. When I used the default...
2
by: uknees | last post by:
Hi, I want to have a datagrid filled with data for the users to select which ever record they want and poplulate to another datagrid on another form(which is the calling form) Very much like...
10
by: Brian Link | last post by:
I have a column called "DefaultYN" in a resultset. It appears as a boolColumn. What I'd like to do is to ensure that only one row at a time can be selected as the "Default" row. Unfortunately, I...
2
by: magmo | last post by:
Hi I try to loop through a datagrid to see if the checkbox in the datagrid is selected using this code.. <code> Public Function GetSelectedRows(ByVal dg As DataGrid) As...
4
by: Dany P. Wu | last post by:
Hi everyone, I'm not entirely sure if this is the best way of going about it, but here's the scenario.......... I have two datagrid, each bound to a datatable which have checkbox columns....
4
by: Agnes | last post by:
In my datagrid, there is Boolcolumn, i allow the user to click it . Now, i need to update the table which the boolcolumn is True. if the column is false, I should not save those row. How can I do...
3
by: Bronislav | last post by:
I need to add editable check box column to the data grid. I have field in the SQL table with the type tinyint, which is translated to the unsigned bite in the datatable. I added DataGridBoolColumn...
1
by: Ludwig | last post by:
Hello NG, how can I integrate a Combobox or a Checkbox in a Datagrid? Thanks, Ludwig
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.