Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Components
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2003, 11:06 PM
Registered User
 
Join Date: Sep 2003
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 :
    [email protected]
 
Old November 5th, 2004, 05:14 AM
Registered User
 
Join Date: Nov 2004
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 !!!

 
Old November 5th, 2004, 03:11 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old March 8th, 2006, 07:58 AM
Registered User
 
Join Date: Mar 2006
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 [email protected]


Please let me know


Regards,
Saravanan.






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





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