I have a datagrid bound to dataset where some entries are null. In that grid
I am defining a column as Boolean (see code below) and I get the expected
checkbox which is checked or unchecked when the DB value is 0 or 1 but when
it is null, I get a grayed out checkbox that is checked. I want the null
values to display nothing - like with the null text in a textbox. How can I
accomplish that?
TIA
Wayne
============= Code to define column ==================
' Define Wait Column
Dim objWaitCol As New DataGridBoolColumn
objWaitCol.MappingName = "Wait"
objWaitCol.HeaderText = "Wait"
objWaitCol.Width = 50
objWaitCol.Alignment = HorizontalAlignment.Center
objWaitCol.NullText = ""
'Add the column to the styles
objRegsDataGridTableStyle.GridColumnStyles.Add(obj WaitCol) 4 1415
Hi,
Go through the data and change any nulls to false.
Dim conn As SqlConnection
Dim strConn As String
Dim strSQL As String
Dim da As SqlDataAdapter
strConn = "Server = (local);"
strConn &= "Database = NorthWind;"
strConn &= "Integrated Security = SSPI;"
conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * From Products", conn)
da.Fill(ds, "Products")
Dim dr As DataRow
For Each dr In ds.Tables("Products").Rows
If dr.IsNull("Discontinued") Then
dr.BeginEdit()
dr.Item("Discontinued") = False
dr.EndEdit()
End If
Next
Ken
----------------
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...
I have a datagrid bound to dataset where some entries are null. In that grid
I am defining a column as Boolean (see code below) and I get the expected
checkbox which is checked or unchecked when the DB value is 0 or 1 but when
it is null, I get a grayed out checkbox that is checked. I want the null
values to display nothing - like with the null text in a textbox. How can I
accomplish that?
TIA
Wayne
============= Code to define column ==================
' Define Wait Column
Dim objWaitCol As New DataGridBoolColumn
objWaitCol.MappingName = "Wait"
objWaitCol.HeaderText = "Wait"
objWaitCol.Width = 50
objWaitCol.Alignment = HorizontalAlignment.Center
objWaitCol.NullText = ""
'Add the column to the styles
objRegsDataGridTableStyle.GridColumnStyles.Add(obj WaitCol)
Thanks for the reply Ken. I'll give that a try.
Wayne
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uM*************@TK2MSFTNGP10.phx.gbl... Hi,
Go through the data and change any nulls to false.
Dim conn As SqlConnection
Dim strConn As String
Dim strSQL As String
Dim da As SqlDataAdapter
strConn = "Server = (local);"
strConn &= "Database = NorthWind;"
strConn &= "Integrated Security = SSPI;" conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * From Products", conn)
da.Fill(ds, "Products")
Dim dr As DataRow
For Each dr In ds.Tables("Products").Rows
If dr.IsNull("Discontinued") Then
dr.BeginEdit()
dr.Item("Discontinued") = False
dr.EndEdit()
End If
Next Ken
----------------
"Wayne Wengert" <wa***************@wengert.com> wrote in message news:ul**************@TK2MSFTNGP10.phx.gbl... I have a datagrid bound to dataset where some entries are null. In that
grid I am defining a column as Boolean (see code below) and I get the expected checkbox which is checked or unchecked when the DB value is 0 or 1 but
when it is null, I get a grayed out checkbox that is checked. I want the null values to display nothing - like with the null text in a textbox. How can
I accomplish that?
TIA
Wayne
============= Code to define column ================== ' Define Wait Column
Dim objWaitCol As New DataGridBoolColumn
objWaitCol.MappingName = "Wait"
objWaitCol.HeaderText = "Wait"
objWaitCol.Width = 50
objWaitCol.Alignment = HorizontalAlignment.Center
objWaitCol.NullText = ""
'Add the column to the styles
objRegsDataGridTableStyle.GridColumnStyles.Add(obj WaitCol)
Hi,
Another method. I created a new datagridboolcolumn which
automatically converts nulls to false. Use this in your tablestyle instead
of the datagridboolcolumn.
Public Class NoNullBoolColumn
Inherits DataGridBoolColumn
Protected Overrides Function GetColumnValueAtRow(ByVal lm As
System.Windows.Forms.CurrencyManager, ByVal row As Integer) As Object
Dim objNull As Object = Convert.DBNull
If objNull.Equals(MyBase.GetColumnValueAtRow(lm, row)) Then
Return False
Else
Return MyBase.GetColumnValueAtRow(lm, row)
End If
End Function
End Class
Ken
-----------------------
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uM*************@TK2MSFTNGP10.phx.gbl...
Hi,
Go through the data and change any nulls to false.
Dim conn As SqlConnection
Dim strConn As String
Dim strSQL As String
Dim da As SqlDataAdapter
strConn = "Server = (local);"
strConn &= "Database = NorthWind;"
strConn &= "Integrated Security = SSPI;"
conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * From Products", conn)
da.Fill(ds, "Products")
Dim dr As DataRow
For Each dr In ds.Tables("Products").Rows
If dr.IsNull("Discontinued") Then
dr.BeginEdit()
dr.Item("Discontinued") = False
dr.EndEdit()
End If
Next
Ken
----------------
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...
I have a datagrid bound to dataset where some entries are null. In that grid
I am defining a column as Boolean (see code below) and I get the expected
checkbox which is checked or unchecked when the DB value is 0 or 1 but when
it is null, I get a grayed out checkbox that is checked. I want the null
values to display nothing - like with the null text in a textbox. How can I
accomplish that?
TIA
Wayne
============= Code to define column ==================
' Define Wait Column
Dim objWaitCol As New DataGridBoolColumn
objWaitCol.MappingName = "Wait"
objWaitCol.HeaderText = "Wait"
objWaitCol.Width = 50
objWaitCol.Alignment = HorizontalAlignment.Center
objWaitCol.NullText = ""
'Add the column to the styles
objRegsDataGridTableStyle.GridColumnStyles.Add(obj WaitCol)
Thanks - I'll try that out!
Wayne
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:et*************@tk2msftngp13.phx.gbl... Hi,
Another method. I created a new datagridboolcolumn which automatically converts nulls to false. Use this in your tablestyle
instead of the datagridboolcolumn.
Public Class NoNullBoolColumn
Inherits DataGridBoolColumn
Protected Overrides Function GetColumnValueAtRow(ByVal lm As System.Windows.Forms.CurrencyManager, ByVal row As Integer) As Object
Dim objNull As Object = Convert.DBNull
If objNull.Equals(MyBase.GetColumnValueAtRow(lm, row)) Then
Return False
Else
Return MyBase.GetColumnValueAtRow(lm, row)
End If
End Function
End Class Ken
-----------------------
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:uM*************@TK2MSFTNGP10.phx.gbl... Hi,
Go through the data and change any nulls to false.
Dim conn As SqlConnection
Dim strConn As String
Dim strSQL As String
Dim da As SqlDataAdapter
strConn = "Server = (local);"
strConn &= "Database = NorthWind;"
strConn &= "Integrated Security = SSPI;" conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * From Products", conn)
da.Fill(ds, "Products")
Dim dr As DataRow
For Each dr In ds.Tables("Products").Rows
If dr.IsNull("Discontinued") Then
dr.BeginEdit()
dr.Item("Discontinued") = False
dr.EndEdit()
End If
Next Ken
----------------
"Wayne Wengert" <wa***************@wengert.com> wrote in message news:ul**************@TK2MSFTNGP10.phx.gbl... I have a datagrid bound to dataset where some entries are null. In that
grid I am defining a column as Boolean (see code below) and I get the expected checkbox which is checked or unchecked when the DB value is 0 or 1 but
when it is null, I get a grayed out checkbox that is checked. I want the null values to display nothing - like with the null text in a textbox. How can
I accomplish that?
TIA
Wayne
============= Code to define column ================== ' Define Wait Column
Dim objWaitCol As New DataGridBoolColumn
objWaitCol.MappingName = "Wait"
objWaitCol.HeaderText = "Wait"
objWaitCol.Width = 50
objWaitCol.Alignment = HorizontalAlignment.Center
objWaitCol.NullText = ""
'Add the column to the styles
objRegsDataGridTableStyle.GridColumnStyles.Add(obj WaitCol) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: gokul |
last post by:
Hi,
Iam a newbie to dotnet and I experience problems in using the Browser
control in VB .net. Though Iam able to use it with its basic features,
I need to customise it.
...
|
by: jez123456 |
last post by:
Not sure if I'm in the right thread but here goes.
I have an ASP.Net web page with a datagrid. The code behind is C#.
If the datagrid has no records the datagrid header section is still shown....
|
by: Das |
last post by:
Hi everyone,
I'm using datagrid control to display the data. I want to hide column to be
displayed into the data grid. I'm using the code as given below:
Method given below is used to bind the...
|
by: Raj |
last post by:
Hi,
When we are sorting the DataGrid Boolean column the grid is becoming
redcross.
I have my own PPMIPDataGridBoolColumn class inherited from
System.Windows.Forms.DataGridBoolColumn. In this...
|
by: |
last post by:
I have a page where I have 3 combo boxes listed in a column. sort of like:
combo1
combo2
combo3
Based on which one is clicked, the others are supposed to hide (i.e.
combobox.visible =...
|
by: sivaraman.S |
last post by:
Hi friends,
How to hide a column in datagrid.
regards,
Sivaraman.S
|
by: J |
last post by:
Ok, they have changed a lot of stuff in VB.net. How in the world do you hide a column on the Datagrid?
--
Jason
|
by: hazz |
last post by:
ICollection CreateDataSource() {
dt.Columns.Add(new DataColumn("ReportInclude", typeof(Boolean)));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr = 0;
dt.Rows.Add(dr); }
void...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| |