If you need to use a CheckBox in a Grid, you have 2 choices, either use the ListView control which is limited in it's ability to set different styles in it's cells, or you can use this little set of fuctions.
First build your Form, add a MSFlexGrid control, be sure to add the Microsoft FlexGrid Control from Project > Components. Add 2 PictureBox objects, these will contain the checked and unchecked images.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:
Re-scan downloaded files using your personal virus checker before using it.
NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Scan the source code with Minnow's Project Scanner
If you don't have a virus scanner, you can get one at many places on the net
Terms of Agreement:
By using this code, you agree to the following terms...
You may use
this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this code from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
hey! This is a nice, Cool and clean Trick!!!;):D:). I was looking for this for a LONG TIME!!!!! i will use this thinigie in my app:) AAhhmmmpucH!:D really helpful! 5 cookies from me.:D (If this comment was disrespectful, please report it.)
I would use this code in my app;) I was wondering why didn't this simple code came in my mind before!:D anyway thanks for sharing this code;) I hope others people also find it interesting to use! (If this comment was disrespectful, please report it.)
10/23/2002 2:39:41 PM:
Yeah, I was going nuts trying to figure out how to do this...
Keep an eye open for my other tricks with the MSFlexGrid, like alternating row colors, sorting on columns, passing hidden column data, etc... ;-) (If this comment was disrespectful, please report it.)
10/24/2002 5:33:30 AM:
that's really good. i was looking for something similar with a datagrid but this was really helpfull. thanks (If this comment was disrespectful, please report it.)
I keep getting an errors and the project does not work for me. What could I be doing wrong?
Line 16: Property Picture in picChecked had an invalid file reference. Line 27: Property Picture in picUnchecked had an invalid file reference. Line 16: Property Picture in picChecked had an invalid file reference. Line 27: Property Picture in picUnchecked had an invalid file reference.
(If this comment was disrespectful, please report it.)
'use Project/Components/Microsoft FlexGrid Control 6.0 Private Sub MSFlexGrid1_DblClick() With MSFlexGrid1 .Move 0, 0, 5000, 2000 .Cols = 4 .Rows = 4 If .Col = 1 And .Row = 1 Then .CellFontName = "wingdings" .CellFontSize = 13 If .Text = Chr(168) Then .Text = Chr(254) .TextMatrix(1, 0) = "checked" Else .Text = Chr(168) .TextMatrix(1, 0) = "unchecked" End If Else .CellFontName = "small fonts" .CellFontSize = 7 .Text = "chk " & Right(Rnd, 1) End If End With End Sub (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular code, please
click here instead.)