473,486 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

datagridview check if font is bold

5 New Member
I need to check if fonts are bold or not within each cell. I can easily change the font to bold but I can't seem to get a true/false after I have written to the cell to see if it is bold or not.

Should this not work?
If Me.DataGridView1.Item(x, y).Style.Font.Bold Then

Thanks

Mike
Feb 13 '08 #1
6 3706
Killer42
8,435 Recognized Expert Expert
Should this not work?
If Me.DataGridView1.Item(x, y).Style.Font.Bold Then
What happens when you do that?

Note, it might be necessary to create a new font object and set it to match the one that's in the cell, then use that. There were cases in VB6 where this is necessary, so maybe it's still hanging around.
Feb 14 '08 #2
coopdog
5 New Member
What happens when you do that?

Note, it might be necessary to create a new font object and set it to match the one that's in the cell, then use that. There were cases in VB6 where this is necessary, so maybe it's still hanging around.

It returns an error for any cell that does not contain bold text.

I cheated and created a function that will check for bold and catches the error if it is not then returns true or false. Not sure if this is the best solution but it seems to work.

Thanks for the reply

Mike
Feb 15 '08 #3
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Yes, in VB.net, It works alright if the Font is Bold,
but if not Bold then you will get Null Reference Exception,
this is work around.

Expand|Select|Wrap|Line Numbers
  1. Dim TFlg As Boolean
  2. Try
  3.     TFlg = DataGridView1.Item(2, 5).Style.Font.Bold
  4. Catch ex As Exception
  5.     TFlg = False
  6. End Try
  7. MsgBox(TFlg)
  8.  
Regards
Veena
Feb 15 '08 #4
Killer42
8,435 Recognized Expert Expert
Yes, in VB.net, It works alright if the Font is Bold, but if not Bold then you will get Null Reference Exception ...
Wow! What an amazinlgy stupid language feature. :(

I hope someday we get a programming language that we can work with instead of around.
Feb 17 '08 #5
coopdog
5 New Member
Thanks for all the help, that is almost exactly what I came up with in my little function.

Thanks again

Mike
Feb 19 '08 #6
Killer42
8,435 Recognized Expert Expert
Shouldn't you be checking the type of exception?
Feb 19 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5157
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form...
3
11743
by: thomasp | last post by:
I know this is a vague question, but I am not sure what information to give. I am using VB2005 beta and the datagridview is pulling data from one of three tables in an Access database. For some...
4
11083
by: Matt | last post by:
Another interesting issue: I set the default font on most of my forms to what I want the text in my controls to show up as (say, Verdana 9pt.), and then just change the font on labels and buttons...
0
415
by: Mark Carew | last post by:
Hi, I'm writing a winform app (as practice) that has as one of its features a button that reads an xml file to a datagridview. No matter what I do I get two columns instead of one. The...
0
2271
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the...
2
17171
by: Steve Richter | last post by:
I set the Text of a DataGridView control expecting this text to be displayed at the top of the control, as the grid title. But the text does not display. How do I display title text above the...
2
7728
by: =?Utf-8?B?UmljaA==?= | last post by:
I have code to bold text in a datagridviewcell: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cs As DataGridViewCellStyle, fnt...
1
3353
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
1
8459
by: gmcconville | last post by:
Im a little bit stuck on how to change a cell in a datagridview to bold without affecting any of the other attributes of the cell, such as underline, italic etc. This is what I thought would work...
0
7123
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,...
0
7175
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...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
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...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
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...

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.