Solved

Boolean Column Datagrid checkbox threestate

Posted on 2004-08-02
10
659 Views
Last Modified: 2008-01-09
I have a C# form with a datagrid and in that i have used TableStyles and DataGridColumn styles. My problem is with a Boolean column. A checkbox appears in the column but when clicked it goes as grayed out just after being checked. i.e. on clicking it must toggle as checked-unchecked-checked..........................  but it is going as checked-grayed-unchecked-checked-grayed-unchecked. I want to remove the grayed out condition so that on each click it just toggles between check and uncheck and is never grayed out. I have already set the AllowNull property of TableStyle to false but still cant get it done. Please help!!!!
Prashant
0
Comment
Question by:prashantagarw10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11699260
http://www.syncfusion.com/forums/message.asp?MessageID=1450 i didnt know the second part .. thanks for teaching me something :)
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 11701044
Set the AllowNull property of the Column Style to false (you said you already did that). This should immediately disallow the three states if the column in the underlying datasource is of a boolean type. Only in the beginning, when a new row is created, it will still show with gray. To remove this, in your data table which is the data source for the data grid, you need to set a default value to either true or false. This will solve the initial value problem as well.
0
 
LVL 1

Expert Comment

by:janeburton
ID: 11704020
under style, there's a selectedItemStyle, make sure u didn't set any color properties there.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 5

Author Comment

by:prashantagarw10
ID: 11704682
I see your solutions. But just now i found something real amazing. When i bind the same DataGrid to another datatable in same dataset then the problem disappears. The dataset has been built from a XML file with 2 tables in it. The one i am using is the child table and just to test i used the parent table and then it did not show any gray state in checkbox so i guess something to do in datatable. Can nay of u think on that line ? I have already tried setting Datatable columns to AllowDBNull=False and also given a default value to each such boolean column. Also i have checked the values in run mode and found no nulls at all. No rows can be added or deleted from any datatable, they can only be modified. and i did check to not set any colors in any property and it just comes when toggling the checkbox. Think guys!!!!!!!
Prashant
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 11704713
You need to set the default value in the dataset. Select the column and search for the default value property. This is the value for new rows, so you cannot see it in existing rows
0
 
LVL 5

Author Comment

by:prashantagarw10
ID: 11706692
I have set the default value in dataset too. But no luck my friend. Just cant do it. I also tried more combinations and found that whenever i bound any grid to this datatable then the grayed checkbox appears except for when i bind it to datagrid which is currently being used by the other datatable in the same dataset.
0
 
LVL 5

Author Comment

by:prashantagarw10
ID: 11708892
Hi guys
I have myself found the solution. I had actually done some code to remove a few columns from the dataset while it was used for generating TableStyles and GridColumnStyles. the columns were not required in the datagrid so i had removed them. now i just made them invisible by seeting their width to 0 so now all works fine.
but thanks for all your help.
Prashant
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11981808
PAQed, with points refunded (250)

Netminder
Site Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question