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 How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 July 22nd, 2005, 01:39 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do i add checkboxes on Flexgrid ?

Hi !,
I need to add checkboxes in my flexgrid. The code is:

Code:
For i = 1 To rs.RecordCount - 1

            'Need to add code on this line 
            'as checkboxes will appear in 1st column                        

            grid.TextMatrix(i, 1) = Day(rs(1)) & Space(1) & MonthName(Month(rs(1)), True) & Space(1) & Year(rs(1)) & ""
            grid.TextMatrix(i, 2) = rs(2)
            grid.TextMatrix(i, 3) = rs(3) & ""
            grid.TextMatrix(i, 4) = rs(4) & ""
            grid.TextMatrix(i, 5) = rs(5)
            grid.TextMatrix(i, 6) = rs(6) & ""
            rs.MoveNext
Next
I also saw the below thread related to this topic but here i need control array.

http://p2p.wrox.com/topic.asp?TOPIC_ID=4611

Regards,

Vinay


Reply With Quote
  #2 (permalink)  
Old July 22nd, 2005, 04:21 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello

Check this link
http://in.geocities.com/raghavendra_...oFlexGrid2.zip

It contains then vb project. I have written the code to add the
checkboxes to the MSHFlexgrid. It adds in the form of control
array.

Please check this and let me know.

Hope this helps.

With Regards,
Raghavendra Mudugal
Reply With Quote
  #3 (permalink)  
Old August 1st, 2005, 12:19 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Raghavendra,

Thanks for the code. I can generate checkboxes on Flexgrid but now the problem arises when the records to be displayed are more than the one that can be accomodated in the flexgrid. In such case when i check any record (say nth record) and scroll down, then allways the nth checkbox in the flexgrid view is shown checked,though the record details are different. The flexgrid view (in relation to checkbox) seems fixed on scrolling down.

Let me explain it further. Suppose i check 2,3 and 6th record
in the flexgrid. When i scroll down then the corresponding 2,3 and 6th record in the current view are shown checked though the original 2,3 and 6th records have scrolled up. This view remains fixed till i scroll to the end.The values that I get of the checked checkboxes are those of the original ones.

Any idea how to fix this?

Regards,

Vinay
Reply With Quote
  #4 (permalink)  
Old August 1st, 2005, 02:04 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Vinay

Yes, it works for only fixed set of rows. Because those checkbox are not part of the grid, it
just sits on the top of each cell positioning as if they are in the grid.

I am working on it and let you soon as i complete it.

And SORRY for incomplete code.

With Regards,
Raghavendra Mudugal
Reply With Quote
  #5 (permalink)  
Old August 1st, 2005, 01:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I answer a similar thread just today:

http://forums.devx.com/showthread.php?t=145283

Marco
Reply With Quote
  #6 (permalink)  
Old August 1st, 2005, 10:52 PM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Marco,

I've seen the icon solution elsewhere also. But my requirements are that in the flexgrid invoices will be displayed and the records with checked checkboxes should be flagged in the database on button click. In case of checkbox control i can name all checkboxes with their respective record ids and can retrieve the records that need to be flagged.

Can you please guide me to a different approach that i may use in case of image checkboxes, the main aim is to get the record ids(fetched from recordset) corresponding to checked records.


Regards,

Vinay

Reply With Quote
  #7 (permalink)  
Old August 2nd, 2005, 12:10 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Vinay, In that case use this simple solution

Add a MSHflexgrid and copy and paste this code

Private Sub Form_Load()
s = Me.MSHFlexGrid1.Rows
For q = 1 To s - 1
    Me.MSHFlexGrid1.Col = 1
    Me.MSHFlexGrid1.Row = q
    Me.MSHFlexGrid1.CellFontName = "Wingdings"
    Me.MSHFlexGrid1.TextMatrix(q, 1) = "o"
Next
End Sub

Private Sub MSHFlexGrid1_Click()
If Me.MSHFlexGrid1.TextMatrix(Me.MSHFlexGrid1.RowSel, 1) = "o" Then
    Me.MSHFlexGrid1.TextMatrix(Me.MSHFlexGrid1.RowSel, 1) = "þ"
Else
    Me.MSHFlexGrid1.TextMatrix(Me.MSHFlexGrid1.RowSel, 1) = "o"
End If
End Sub

I guess, it must give you some anothere thought to approch.
Please check this and let me know.

Hope this helps

With Regards,
Raghavendra Mudugal
Reply With Quote
  #8 (permalink)  
Old August 2nd, 2005, 12:56 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Raghavendra,

Your code adds a text in Wingdings which appears to be a checkbox.
What my requirements are:

Records are looped through the recordset and displayed in the flexgrid. The first column should have checkboxes corresponding to each record. On a button click all the records that are checked are processed and flagged in the database. So the basic requirement is to fetch the id (recordset field ) corresponding to each checked record. In case of checkbox control i can name each checkbox with the recordset id and can thus fetch the required value.

I hope I might be able to clarify my requirements.

Thanks for the help.

Regards,

Vinay

Reply With Quote
  #9 (permalink)  
Old August 2nd, 2005, 01:17 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Vinay

I came to know your doubt and my previous posting is what it tells you to do.
Rather than using the check box, and checking for vbChecked or vbUnchecked,
and processing all the records from the flexgrid, just consider that Wingding
text "þ" (checked box) as that row is selected for processing and take all the
data what you want from that row and set the flag in the table.

It is better to think for alternate, rathar than adding checkbox control
100 times (and might depend on the recordcount of the recordset), go for
so easy way. I guess you are getting what i am truing to say.

Hope this helps


With Regards,
Raghavendra Mudugal
Reply With Quote
  #10 (permalink)  
Old August 2nd, 2005, 03:44 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Raghavendra,

Thanks for that. One last final thing is left which is the nub of the problem.
I can display these checkboxes(Webdings) but how to fetch the record id (which is primary key in the table and is not to be displayed in the flexgrid). I do code mainly ASP where we set the value of checkboxes to that of the record field value and thus perform required operation on the checked ids.

But how to get Id in this case. Though i can hide one column (width=1) and put the id field value in that. Any better idea other than this?

Regards,

Vinay

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
FlexGrid amlesh Beginning VB 6 0 July 26th, 2007 01:31 AM
Vs-flexgrid MathLearner Beginning VB 6 0 June 4th, 2007 01:52 AM
FlexGrid and Add Control santanu.roy VB Components 0 June 21st, 2006 04:49 AM
how to add checkboxes in this asp gilgalbiblewheel Classic ASP Databases 1 August 10th, 2004 12:17 AM
FLEXGRID...HELP!!! apek VB How-To 4 January 20th, 2004 05:19 PM



All times are GMT -4. The time now is 04:32 PM.


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