p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB How-To (http://p2p.wrox.com/forumdisplay.php?f=78)
-   -   How do i add checkboxes on Flexgrid ? (http://p2p.wrox.com/showthread.php?t=31749)

Raghavendra_Mudugal August 2nd, 2005 04:29 AM

Hello Vinay

For that you can use this

Private Sub Form_Load()
For q = 1 To Me.MSHFlexGrid1.Rows - 1
    Me.MSHFlexGrid1.ColData(1) = q
    Me.MSHFlexGrid1.RowData(q) = q
End Sub

Private Sub MSHFlexGrid1_Click()
MsgBox Me.MSHFlexGrid1.RowData(Me.MSHFlexGrid1.RowSel)
End Sub

ColData and RowData stores extra numeric information that we can
use programatically. And those values are not visible to
any one.

Hope this helps

With Regards,
Raghavendra Mudugal

leo_vinay August 2nd, 2005 05:34 AM

Hi Raghavendra,

Again am stuck..

The problem is that am fetching that id from a temporary table which stores id from two different tables, hence prefixes id with a single character, depending upon the table it is coming from.

So Me.grid.ColData(1)=rs("field_type_id") gives "type mismatch" as it happens to be alphanumeric.

Also is there any way to store the data only in 1st column and not in all columns of all rows,becaus when i code only for ColData and not RowData then the data is not stored.



Raghavendra_Mudugal August 2nd, 2005 06:01 AM


Coldata and Rowdata stores only numeric (long type).
For storing the ID in only first column, just pass the index
of the first column. and loop through the rows my incrementing
the row index. See the example in my previous post.

For storing the ID what you can do is the best.. while you
add to the flexgrid say ID = "EMP1" (something like this)
remove the "EMP" while you add just store "1" in the RowData
and for updating the flag in the table there you attach "EMP"
with the ID of the row selected. So again it becomes "EMP1"
which you can find the rows with this ID in the table.

I guess it is clear to you.

Hope this helps

With Regards,
Raghavendra Mudugal

Raghavendra_Mudugal August 2nd, 2005 06:16 AM


you can take an array of string and load the IDs to this
and while updating the table get the ID from that array
with respect to the row number. So you will have the
IDs exactly as it is the table.

2. Load the IDs in saperate column at the end of columns and
set the colwidth to 1 which is like , it exists but it cannot
be viewed and make sure that you do not allow the column
resize. (if yes then above 1st point is what i see now)

Hope this helps

With Regards,
Raghavendra Mudugal

leo_vinay August 2nd, 2005 06:38 AM

Done with the Array.

Many thanks Raghavendra.



marcostraf August 2nd, 2005 12:39 PM

If the check box needs to go only in the first column, it is much easier just to use a ListView in Report mode, that has that capability built in. Not only that, but when you add a row you can assign an alphanumeric Tag to each row, that can be used in your case to store a record id. Thus, no need either for images, extra arrayes or an extra font (that needs to be distribuited with the application).

tina6482 February 10th, 2006 08:29 AM

hi Raghavendra

i ned help with vb.

i have to populate say n numbers in a flexgrid, which i am able to do from a database.

now i have to add checkbox for each number such that on checking a particular number checkbox, tht number is added in another table of a database.

also the numbers are populated by selecting options from two combo boxes.

kindly help at the earliest.

tina6482 February 10th, 2006 08:34 AM


i can populate the numbers.

i need help only with the checkboxes. i have seen ur previous replies.

but i hav noticed, tht on chking the flexgrid anywhere, the chkbox is selected.

how do i add 100 chkboxes?

please help at the earliest.


saravanan_article March 8th, 2006 08:04 AM

Hi Vinay and Ragavendra,

I am using Flexgrid in C#.. I want to place a checkboxes in that.. I tried to handle the "ClickEvent" Event of flexgrid and wrote the following code

                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                    chkSelect.Visible = true;
                    chkSelect.Left = axMSFlexGrid1.Left + axMSFlexGrid1.CellLeft;
                    chkSelect.Top = axMSFlexGrid1.Top + axMSFlexGrid1.CellTop;
                    if(axMSFlexGrid1.Text == "Selected")
                        chkSelect.Text ="1";
                        chkSelect.Text = "0";

                    chkSelect.Visible = true;


but its not showing me the checkboxes.. Will u please correct the problem if any and give me a solution for that... Please its very urgent



All times are GMT -4. The time now is 12:07 PM.

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