Important alert: (current site time 10/24/2014 11:02:12 AM EDT)
 

winzip icon

CheckBox in MSFlexGrid

Email
Submitted on: 10/23/2002 12:44:50 PM
By: mgfranz 
Level: Intermediate
User Rating: By 21 Users
Compatibility: VB 6.0
Views: 40845
(About the author)
 
     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.

 
winzip iconDownload code

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:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. 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 including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. 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.
  2. 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.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

10/23/2002 2:21:47 PMBrainBenchers

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.)

 
10/23/2002 2:28:52 PMBrainBenchers

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.)

 
10/26/2002 8:32:15 PMProgramming Animal

Thanks for the code! I've used a listbox control in the past but that did not always do what I wanted.

Thanks again!
(If this comment was disrespectful, please report it.)

 
11/25/2002 4:08:42 PMJamie GGG

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.)

 
11/25/2002 4:19:39 PMmgfranz

It's not you, the images for the checkbox's were not included in the original .zip file. I am attempting to upload an updated copy now.
(If this comment was disrespectful, please report it.)

 
11/26/2002 12:17:05 AM

Can u kindly send me the images to rooseveltmaya@yahoo.com
(If this comment was disrespectful, please report it.)

 
11/26/2002 11:43:19 AMmgfranz

The images are in the .zip file now.
(If this comment was disrespectful, please report it.)

 
6/8/2005 7:18:53 AMTom Pydeski

you can also set cellfontname to wingdings and use the following to look like a check:
Const strChecked = ""
Const strUnChecked = "q"

(If this comment was disrespectful, please report it.)

 
6/8/2005 8:48:53 AMNorm Cook

Const strUnChecked = ""
or Chr$(&HA8) seems to be better.
(If this comment was disrespectful, please report it.)

 
7/15/2013 1:04:37 PMvb_elmar

wingdings characters:
Chr$(253) cross in a box
Chr$(254) hook in a box
Chr$(168) empty box

(If this comment was disrespectful, please report it.)

 
7/16/2013 12:53:58 AMvb_elmar

'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.)
 

To post feedback, first please login.