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

July 22nd, 2005, 01:39 AM
|
Authorized User
|
|
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 22nd, 2005, 04:21 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 1st, 2005, 12:19 AM
|
Authorized User
|
|
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 1st, 2005, 02:04 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

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

August 1st, 2005, 10:52 PM
|
Authorized User
|
|
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 2nd, 2005, 12:10 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 2nd, 2005, 12:56 AM
|
Authorized User
|
|
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 2nd, 2005, 01:17 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 2nd, 2005, 03:44 AM
|
Authorized User
|
|
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |