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
6 3706
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.
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
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. -
Dim TFlg As Boolean
-
Try
-
TFlg = DataGridView1.Item(2, 5).Style.Font.Bold
-
Catch ex As Exception
-
TFlg = False
-
End Try
-
MsgBox(TFlg)
-
Regards
Veena
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.
Thanks for all the help, that is almost exactly what I came up with in my little function.
Thanks again
Mike
Shouldn't you be checking the type of exception?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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:...
|
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...
|
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: 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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |