Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Components
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Components Issues specific to components in VB.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Components section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 26th, 2003, 11:06 PM
Registered User
 
Join Date: Sep 2003
Location: Dhaka, Baddah, Bangladesh.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding a Checkbox to a FlexGrid using VB 6.0

Does anyone know how can I use check box inside the flexgrid using Visual Basic 6.0.

I want to check and uncheck some Information in a grid according to my business.

If some one knows how to do it pls tell me how can I do it
and pls send me the code of it.

My email Address is :
    mdfazlulkarim@yahoo.com
Reply With Quote
  #2 (permalink)  
Old November 5th, 2004, 05:14 AM
Registered User
 
Join Date: Nov 2004
Location: nasik, maharashtra, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'''paste following code
''where
'''
''' grid1 is flexgrid control
''' chkSelect is Check box Control

Dim lrow As Integer
Dim lcol As Integer

Private Sub Grid1_Click()
    Select Case Grid1.Col
        Case 2: chkSelect.Visible = True
                chkSelect.Left = Grid1.Left + Grid1.CellLeft
                chkSelect.Top = Grid1.Top + Grid1.CellTop
                If Grid1.Text = "Selected" Then
                    chkSelect.Value = "1"
                Else
                    chkSelect.Value = "0"
                End If
                chkSelect.SetFocus
                chkSelect.Visible = True
        lrow = Grid1.Row
        lcol = Grid1.Col
    End Select
End Sub

Private Sub chkSelect_LostFocus()
  If chkSelect.Value = 1 Then
        Grid1.TextMatrix(lrow, lcol) = "Selected"
    Else
        Grid1.TextMatrix(lrow, lcol) = "Skip"
    End If
    chkSelect.Visible = False
End Sub


''' this will surely solve your problem
''' Best Luck !!!

Reply With Quote
  #3 (permalink)  
Old November 5th, 2004, 03:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just to add more documentation on Mr. Beena Brashant code (that is perfectly fine).

chkSelect must be added in the form with the Visible property set to False, no Caption, and sized very small.
The code will work only on column 2, the select case in the Click event must be changed to handle other columns/rows.
The check box is shown at the left of the cell. Text in the grid must be right aligned, or left padded with spaces to avoid being covered by the check box when visible.
Scrolling the grid when the check box is visible will not fire the chkSelect_LostFocus event. Call chkSelect_LostFocus from the Grid_Scroll event.

My preference is to use a context menu instead of a check box, using PopupMenu from the grid mouse down event (but that is just a preference)

Marco
Reply With Quote
  #4 (permalink)  
Old March 8th, 2006, 07:58 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I am using C#.. I tried the same way as per as ur code in VB,, But its not showing me the CheckBoxes.. Please tell me Where is the problem in my code.. If u want my sample code, send me ur mail id.

My id is saravanan_article@yahoo.com


Please let me know


Regards,
Saravanan.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a Checkbox to a FlexGrid using VB 6.0 foka VB Components 1 June 9th, 2007 05:13 AM
adding checkbox to datagrid using javascript k.manisha ASP.NET 1.0 and 1.1 Professional 0 June 4th, 2007 11:02 PM
Adding a checkbox into a listview?? pauljoy Pro VB 6 0 January 9th, 2006 08:04 AM
Adding Checkbox to grid k_kosaraju General .NET 1 March 14th, 2005 06:23 PM
Adding Checkbox column in datagrid anita ASP.NET 1.0 and 1.1 Basics 0 December 20th, 2004 07:16 AM



All times are GMT -4. The time now is 11:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.