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

datagridboolcolumn

(Type your message here)
I use bool column in my datagrid. but I get all grayed checkswhen I first load it. I know it is about the DBNULL state, but ihave set Col.AllowNull = False. my column data type is tinyint,1 or 0. So after I get these value, i convert it to true orfalse.Anyway, i have tried all the way i can think about, itstill not work. can you help? thanks.

I post my code here.

Private Sub frmModComps_Load(ByVal sender As System.Object, ByVale As System.EventArgs) Handles MyBase.Load
conString = "....."

daModComps = New OdbcDataAdapter("....." ,conString)
daModComps.Fill(ds, "table")
CustimizeDataGrid()

Dim i As Integer
With dsModComps.Tables(0)
For i = 0 To .Rows.Count - 1
If .Rows(i)("active") = 1 Then
.Rows(i)("active") =Convert.ToBoolean(.Rows(i)("active"))
ElseIf .Rows(i)("active") = 0 Then
.Rows(i)("active") =Convert.ToBoolean(.Rows(i)("active"))
End If
Console.WriteLine(Convert.ToBoolean(.Rows(i)("acti ve")))
Next
End With
grdModComps.DataSource = dsModComps.Tables(0)
End Sub

Private Sub CustimizeDataGrid()
Dim dgts As DataGridTableStyle = NewDataGridTableStyle()
dgts.MappingName = "table"
grid.TableStyles.Clear()

'1. Add a first column style
Dim desCol As New DataGridTextBoxColumn()
desCol.MappingName = "Description"
desCol.HeaderText = "Type"
desCol.Alignment = HorizontalAlignment.Center
desCol.ReadOnly = True
dgts.GridColumnStyles.Add(desCol)

'2. Add a second column style.
Dim activeCol As New DataGridBoolColumn()
activeCol.MappingName = "Active"
activeCol.HeaderText = "Active"
activeCol.AllowNull = False
activeCol.Alignment = HorizontalAlignment.Center
dgts.GridColumnStyles.Add(activeCol)

'3. Add a third column style.
Dim weightCol As New DataGridTextBoxColumn()
weightCol.MappingName = "Weight"
weightCol.HeaderText = "Weight"
weightCol.Alignment = HorizontalAlignment.Center
dgts.GridColumnStyles.Add(weightCol)
' 4. set column width
dgts.GridColumnStyles(0).Width = 150
dgts.GridColumnStyles(1).Width = 100
dgts.GridColumnStyles(2).Width = 87

dgts.DataGrid.Refresh()
grd.TableStyles.Clear()
grd.TableStyles.Add(dgts)
End Sub
--------------------------------
From: Alice April

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>zXnHJROmUEichwy3kbtSfA==</Id>
Nov 16 '05 #1
0 928

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

Similar topics

1
by: Erald Kulk | last post by:
I have a problem with a datagridboolcolumn that drives me almost crazy. I have a sql server table with several columns of which one is a column called ok which is a bit with default value 0. In...
0
by: subT | last post by:
created several tablestyles, added columstyles..added datagridboolcolumn to one of the collections.. I dont have a problem with the required 2 clicks to change a checkbox value, however, on the...
2
by: PeterZ | last post by:
Hi, In the past I've successfully databound a conventional Winforms checkbox to a number column in an Oracle table, where 1 represents true and 0 represents false. The checkbox would be ticked...
4
by: Ubi | last post by:
Hi, my code is: myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean")); DataGridBoolColumn cs1 = new DataGridBoolColumn(); cs1.NullValue=false; cs1.TrueValue=true;...
2
by: James Goodman | last post by:
I have a number of bool columns within a datagrid, but they dont work as expected. The underlying table is Access 2000. The datatype for the underlying fields is Yes/No. I am attempting to...
1
by: Edward Koucherian | last post by:
I'm getting the incorrect display value on my DataGrid column. The field is numeric (1) in the SQL database table The Code is txtCol = New DataGridBoolColumn txtCol.MappingName = "MyCol"...
2
by: nate axtell | last post by:
I'm trying to create a custom DataGridBoolColumn. I inherit DataGridColumnStyle and create a public CheckBox variable. This columnType will be mapped to a dataTable boolean column. What are the...
1
by: B.J. Raiford | last post by:
I have a DataGrid on a form in my application that is bound to an xml file and I have set the table style to contain a few columns with one editable one, a DataGridBoolColumn. I set...
0
by: Ryan Liu | last post by:
Hi, I have a strange problem, should be very simple, take me days I couldn't finger out. Really appreciate if you can help me fine the problem. I am trying to use DataGridBoolColumn, but I...
0
by: Brett Romero | last post by:
I've created a DataGrid DataGridBoolColumn column in a tablestyle and mapped it correctly to a datatable. Problem is the column is always grayed and I can't uncheck it. I have the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.