473,890 Members | 3,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide Boolean Col in DataGrid

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 DataGridBoolCol umn

objWaitCol.Mapp ingName = "Wait"

objWaitCol.Head erText = "Wait"

objWaitCol.Widt h = 50

objWaitCol.Alig nment = HorizontalAlign ment.Center

objWaitCol.Null Text = ""

'Add the column to the styles

objRegsDataGrid TableStyle.Grid ColumnStyles.Ad d(objWaitCol)
Nov 20 '05 #1
4 1437
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(s trConn)

da = New SqlDataAdapter( "Select * From Products", conn)

da.Fill(ds, "Products")

Dim dr As DataRow

For Each dr In ds.Tables("Prod ucts").Rows

If dr.IsNull("Disc ontinued") Then

dr.BeginEdit()

dr.Item("Discon tinued") = False

dr.EndEdit()

End If

Next

Ken

----------------

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:ul******** ******@TK2MSFTN GP10.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 DataGridBoolCol umn

objWaitCol.Mapp ingName = "Wait"

objWaitCol.Head erText = "Wait"

objWaitCol.Widt h = 50

objWaitCol.Alig nment = HorizontalAlign ment.Center

objWaitCol.Null Text = ""

'Add the column to the styles

objRegsDataGrid TableStyle.Grid ColumnStyles.Ad d(objWaitCol)

Nov 20 '05 #2
Thanks for the reply Ken. I'll give that a try.

Wayne

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:uM******** *****@TK2MSFTNG P10.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(s trConn)

da = New SqlDataAdapter( "Select * From Products", conn)

da.Fill(ds, "Products")

Dim dr As DataRow

For Each dr In ds.Tables("Prod ucts").Rows

If dr.IsNull("Disc ontinued") Then

dr.BeginEdit()

dr.Item("Discon tinued") = False

dr.EndEdit()

End If

Next

Ken

----------------

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:ul******** ******@TK2MSFTN GP10.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 DataGridBoolCol umn

objWaitCol.Mapp ingName = "Wait"

objWaitCol.Head erText = "Wait"

objWaitCol.Widt h = 50

objWaitCol.Alig nment = HorizontalAlign ment.Center

objWaitCol.Null Text = ""

'Add the column to the styles

objRegsDataGrid TableStyle.Grid ColumnStyles.Ad d(objWaitCol)

Nov 20 '05 #3
Hi,

Another method. I created a new datagridboolcol umn which
automatically converts nulls to false. Use this in your tablestyle instead
of the datagridboolcol umn.

Public Class NoNullBoolColum n

Inherits DataGridBoolCol umn

Protected Overrides Function GetColumnValueA tRow(ByVal lm As
System.Windows. Forms.CurrencyM anager, ByVal row As Integer) As Object

Dim objNull As Object = Convert.DBNull

If objNull.Equals( MyBase.GetColum nValueAtRow(lm, row)) Then

Return False

Else

Return MyBase.GetColum nValueAtRow(lm, row)

End If

End Function

End Class

Ken

-----------------------

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:uM******** *****@TK2MSFTNG P10.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(s trConn)

da = New SqlDataAdapter( "Select * From Products", conn)

da.Fill(ds, "Products")

Dim dr As DataRow

For Each dr In ds.Tables("Prod ucts").Rows

If dr.IsNull("Disc ontinued") Then

dr.BeginEdit()

dr.Item("Discon tinued") = False

dr.EndEdit()

End If

Next

Ken

----------------

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:ul******** ******@TK2MSFTN GP10.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 DataGridBoolCol umn

objWaitCol.Mapp ingName = "Wait"

objWaitCol.Head erText = "Wait"

objWaitCol.Widt h = 50

objWaitCol.Alig nment = HorizontalAlign ment.Center

objWaitCol.Null Text = ""

'Add the column to the styles

objRegsDataGrid TableStyle.Grid ColumnStyles.Ad d(objWaitCol)


Nov 20 '05 #4
Thanks - I'll try that out!

Wayne

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:et******** *****@tk2msftng p13.phx.gbl...
Hi,

Another method. I created a new datagridboolcol umn which
automatically converts nulls to false. Use this in your tablestyle instead of the datagridboolcol umn.

Public Class NoNullBoolColum n

Inherits DataGridBoolCol umn

Protected Overrides Function GetColumnValueA tRow(ByVal lm As
System.Windows. Forms.CurrencyM anager, ByVal row As Integer) As Object

Dim objNull As Object = Convert.DBNull

If objNull.Equals( MyBase.GetColum nValueAtRow(lm, row)) Then

Return False

Else

Return MyBase.GetColum nValueAtRow(lm, row)

End If

End Function

End Class

Ken

-----------------------

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:uM******** *****@TK2MSFTNG P10.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(s trConn)

da = New SqlDataAdapter( "Select * From Products", conn)

da.Fill(ds, "Products")

Dim dr As DataRow

For Each dr In ds.Tables("Prod ucts").Rows

If dr.IsNull("Disc ontinued") Then

dr.BeginEdit()

dr.Item("Discon tinued") = False

dr.EndEdit()

End If

Next

Ken

----------------

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:ul******** ******@TK2MSFTN GP10.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 DataGridBoolCol umn

objWaitCol.Mapp ingName = "Wait"

objWaitCol.Head erText = "Wait"

objWaitCol.Widt h = 50

objWaitCol.Alig nment = HorizontalAlign ment.Center

objWaitCol.Null Text = ""

'Add the column to the styles

objRegsDataGrid TableStyle.Grid ColumnStyles.Ad d(objWaitCol)

Nov 20 '05 #5

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

Similar topics

17
57413
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. http://www.codeproject.com/books/0764549146_8.asp The above link shows where what I want is achived in C#, but I need t oa cjhive the same in VB .net. Someone help and guidance would be much appreciated.
4
4088
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. What I need is to hide all of the datagrid if there are no records.
6
8422
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 data grid with the db: public static void DataGrid(DataGrid DG,string sql) { //Initialize connection with the db
2
2361
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 inherited class I have one DataGridValueChangedEventHandler event handler. I am overriding Edit() to know the current state of the cell. I am overriding Paint() to know the if the user has been editing the cell. I am also overriding the Commit() to
2
2221
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 = false). However, when I have the bottom one in that column to be the one to be used
3
1715
by: sivaraman.S | last post by:
Hi friends, How to hide a column in datagrid. regards, Sivaraman.S
5
7817
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
6
2973
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 Page_Load(Object sender, EventArgs e) { ItemsGrid.DataSource = CreateDataSource(); void Item_Bound(Object sender, DataGridItemEventArgs e) {
0
10802
Debadatta Mishra
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
9979
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11234
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10827
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10463
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9637
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7170
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6049
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3281
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.