By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,966 Members | 2,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,966 IT Pros & Developers. It's quick & easy.

UBGrid

P: 44
Hi there..
I just wondering are there anyone ever use UBGrid?
it's a standalone program for VB 6.0 that can add checkbox to the grid.


Thanks....
Jan 10 '08 #1
Share this Question
Share on Google+
29 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

If you want only for Check Box, you can very well use MSFlexGrid only..

Regards
Veena
Jan 10 '08 #2

P: 44
To. Ms Veena,
for msflexgrid, will the item data editable?
and how to put a checkbox with msflexgrid?

thanks in advance..
Jan 10 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

There is one Simple Way , To make a Column Check box in MSFlexGrid..

Say, you want to make Column 4 as Selection Column.
FontName Marlett has character "b" looking like a Check-Mark Icon.
What you can do is Set whole of the column name = "Marlett", and In Click-event Toggle between "b" and empty...To Chaneg Font of whole column, write this Code after populating the Grid:
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer 
  2. For i = 1 To Grd.Rows-1 
  3.     Grd.Row =i 
  4.     Grd.Col=4 
  5.     Grd.CellFontname ="Marlett" 
  6. Next 
  7.  
Write this code in Grd_Click Event:

Expand|Select|Wrap|Line Numbers
  1. If Grd.Row >0 And Grd.Col=4 Then 
  2.     If Trim(Grd.Text) = "" Then 
  3.         Grd.Text ="b" 
  4.     Else 
  5.         Grd.Text = "" 
  6.     End If 
  7. End If 
  8.  
And In Save/Print Button, Loop thru the Rows, and Check For
Expand|Select|Wrap|Line Numbers
  1. If Trim(Grd.TextMatrix(2,4)) ="b"  Then
  2.     MsgBox "Row 2 Selected"
  3. Else
  4.    MsgBox "Row 2 Not Selected"
  5. End If
  6.  
It will indicate Selected Row.
This Logic works fine for me..
Alternatively, Webdings font has also got font "a" looking like a Check Mark..
you can use Either..

If you search the Web, many people suggest you to use an Icon or Picture of a Check Mark and load /Remove the Image from the FlexGrid Cell. this is too tedious.

Regards
Veena
Jan 10 '08 #4

P: 44
Dear Ms.Veena,
you really rocks...!!
it's working, although there's no change to the cell font, it still ms sans serif, but that's ok, maybe im gonna use "Yes" as a check mark.
But sadly i cant edit data value of msflexgrid,
i wonder why there's no "AllowUpdate" properties as in DataGrid.

But thanks so much for your help!!
If only i could do something for you in return .. =)
Jan 10 '08 #5

lotus18
100+
P: 866
What does the UBGrid looks like? Is it the same as FlexGrid? I never encountered this control before : )
Jan 10 '08 #6

P: 44
Dear lotus18,

yep it just like other's grid..
but it can put checkbox, combobox, etc inside the grid..

but i dont know how to use it though,
just found it on google search
=)
Jan 10 '08 #7

lotus18
100+
P: 866
Dear lotus18,

yep it just like other's grid..
but it can put checkbox, combobox, etc inside the grid..

but i dont know how to use it though,
just found it on google search
=)
Wow

It sounds amazing. I'll try that grid later : )
Jan 10 '08 #8

QVeen72
Expert 100+
P: 1,445
Dear Ms.Veena,
you really rocks...!!
it's working, although there's no change to the cell font, it still ms sans serif, but that's ok, maybe im gonna use "Yes" as a check mark.
But sadly i cant edit data value of msflexgrid,
i wonder why there's no "AllowUpdate" properties as in DataGrid.

But thanks so much for your help!!
If only i could do something for you in return .. =)
Hi,

Glad, it could help you.
If you really want a Robust Editable Grid, then go for VSFlexGrid.
Its really cool, and you can set all the Properties @ Design Time (like Say Column Width, Row Height, ) and Column Property like CheckBox/Combo/Button/TextBox..etc..

Regards
Veena
Jan 10 '08 #9

P: 44
Hi,

Glad, it could help you.
If you really want a Robust Editable Grid, then go for VSFlexGrid.
Its really cool, and you can set all the Properties @ Design Time (like Say Column Width, Row Height, ) and Column Property like CheckBox/Combo/Button/TextBox..etc..

Regards
Veena
That's ok, i've found a way to edit the data value from msflexgrid.
Thanks so much for your help.. =)
Jan 10 '08 #10

werks
100+
P: 220
Good day,

I'm downloading UBGrid but i don't know how to use it.. can anyone help me?


Better Than Yesterday (-.-)
Jan 10 '08 #11

P: 44
Dear Ms. Veena and other experts,
I was trying to save the content of Msflexgrid for all rows that have the "b" value.

Expand|Select|Wrap|Line Numbers
  1. If cboSales.Text = "" Then
  2.         MsgBox "Choose Sales No!"
  3.     Else 
  4.     With rs
  5.         .ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=salesdb.mdb;Persist Security Info=False"
  6.         .CursorLocation = adUseClient
  7.         .LockType = adLockOptimistic
  8.         .CursorType = adOpenStatic
  9.         .Source = "SELECT * FROM Sales"
  10.         .Open
  11.  
  12.                     For i = 1 To MSFlexGrid1.Rows - 2
  13.                             If MSFlexGrid1.TextMatrix(i, 4) = "b" Then
  14.                                 If Not MSFlexGrid1.TextMatrix(i, 3) < 1 Then
  15.                                      .AddNew
  16.                                      .Fields(0).Value = txtNoSO.Text
  17.                                      .Fields(1).Value = cboSales.Text
  18.                                      .Fields(2).Value = dtDate.Value
  19.                                      .Fields(3).Value = cboCust.Text
  20.                                      .Fields(4).Value = MSFlexGrid1.TextMatrix(i, 0) 'item name
  21.                                      .Fields(5).Value = MSFlexGrid1.TextMatrix(i, 3) 'item qty
  22.                                      .Update                
  23.                                   End If
  24.                                 Else
  25.                                     MsgBox "Please insert a valid qty!"
  26.                                 End If
  27.                             Else
  28.                                 MsgBox "There's nothing to insert!"
  29.                             End If
  30.                Next
  31. End With
  32. End If
I wonder why it only save the first row and then it show an error.
its kinda confusing me..
Jan 12 '08 #12

QVeen72
Expert 100+
P: 1,445
Hi,


Try to change your second IF to :

If Val(MSFlexGrid1.TextMatrix(i, 3)) > 0 Then

Not very sure of the Fields, Use Val( ) Wherever, you are trying to save a Numeric expression, Open the Recordset as Dynamic, instead of Static,
and change the For Loop to :

For i = 1 To MSFlexGrid.Rows-1

Regards
Veena
Jan 13 '08 #13

P: 44
I've made a changed and it still show an error "Subscript out of range".
When i pressed on debug button,
it highlighted this part.

If MSFlexGrid1.TextMatrix(i, 4) = "b" Then

and still only the first row's item being saved.
Jan 13 '08 #14

QVeen72
Expert 100+
P: 1,445
Hi,

revert back to .Rows-2

Try this FOR Loop

Expand|Select|Wrap|Line Numbers
  1. For i = 1 To MSFlexGrid1.Rows - 2
  2.     If MSFlexGrid1.TextMatrix(i, 4) = "b" And Val(MSFlexGrid1.TextMatrix(i, 3)) > 0 Then
  3.               .AddNew
  4.               .Fields(0).Value = txtNoSO.Text
  5.               .Fields(1).Value = cboSales.Text
  6.               .Fields(2).Value = dtDate.Value
  7.               .Fields(3).Value = cboCust.Text
  8.               .Fields(4).Value = MSFlexGrid1.TextMatrix(i, 0) 
  9.               .Fields(5).Value = MSFlexGrid1.TextMatrix(i, 3) 
  10.               .Update                
  11.     End If
  12. Next
  13.  
How many rows are there in Grid..?
What is the PK of the table..?

Regards
Veena
Jan 13 '08 #15

P: 44

How many rows are there in Grid..?
What is the PK of the table..?
There are 5 rows in the grid.
And as for note when the grid consist of 1 item data only (then it become 1 row only), the script works very well.
It will show "subscript out of range" when there are more than 1 itemdata (row).

I've tried the code and it still save first row itemdata only (while there are 5 itemdata) *sad*
Jan 13 '08 #16

QVeen72
Expert 100+
P: 1,445
Hi,

What is the PK of Sales table...?

Regards
Veena
Jan 14 '08 #17

P: 44
Hi,

What is the PK of Sales table...?

Regards
Veena
Forgive me, what PK is?
Jan 14 '08 #18

lotus18
100+
P: 866
Forgive me, what PK is?
PK means "Primary Key"
Jan 14 '08 #19

P: 44
PK means "Primary Key"
I see..
it's SO_No
it can be find at txtnoso.text
Jan 14 '08 #20

QVeen72
Expert 100+
P: 1,445
Hi,

Thats your answer..
Your table has PrimaryKey ..
PK cannot be repeated,
and you are putting in a loop and try to add, the same PK.
obviously, it doesnt add..you will get error

Either Make a Composite PK , or else, remove PK and make some other field as PK..

In such conditions, (SalesNo + SlNo ) together will be the PK..

REgards
Veena
Jan 14 '08 #21

P: 44
Dear Ms. Veena,
i've remove PK from Sales table, and i dont use any PK for now.
but when i run the program it still has the same problem.
it only save the first row item data and then "subscript out of range".
Jan 14 '08 #22

QVeen72
Expert 100+
P: 1,445
Hi,

How many Columns your grid has..?
How have you declared variable "i"...?
Post your Table Structure..


Regards
Veena
Jan 14 '08 #23

P: 44
There are 4 columns in the grid.
Col:
1 -> Item's id
2 -> Item's name
3 -> Qty
4 -> "b" as checkbox

Yup i had declared "i" as integer.

Table structure:
1. SO_No
2. PO_No
3. Date
4. CustomerID
5. ItemID
6. Qty
Jan 14 '08 #24

P: 44
it's to complicated, isnt it? =(
i've tried to change the validation so it will be : only save the cols(3) that is not NULL.

Expand|Select|Wrap|Line Numbers
  1. If cboSales.Text = "" Then
  2.         MsgBox "Choose Sales No!"
  3.     Else 
  4.     With rs
  5.         .ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=salesdb.mdb;Persist Security Info=False"
  6.         .CursorLocation = adUseClient
  7.         .LockType = adLockOptimistic
  8.         .CursorType = adOpenStatic
  9.         .Source = "SELECT * FROM Sales"
  10.         .Open
  11.  
  12.                     For i = 1 To MSFlexGrid1.Rows - 2
  13.  
  14.                                 If Not MSFlexGrid1.TextMatrix(i, 3) < 1 Then
  15.                                      .AddNew
  16.                                      .Fields(0).Value = txtNoSO.Text
  17.                                      .Fields(1).Value = cboSales.Text
  18.                                      .Fields(2).Value = dtDate.Value
  19.                                      .Fields(3).Value = cboCust.Text
  20.                                      .Fields(4).Value = MSFlexGrid1.TextMatrix(i, 0) 'item name
  21.                                      .Fields(5).Value = MSFlexGrid1.TextMatrix(i, 3) 'item qty
  22.                                      .Update                
  23.                                   End If
  24.                                 Else
  25.                                     MsgBox "Please insert a valid qty!"
  26.                                 End If
  27.  
  28.                Next
  29. End With
  30. End If
For that code, if cols(3) consists of NULL value then it will stop working, where there're still others value that is not null.

Did i make a wrong validation?
Jan 16 '08 #25

lotus18
100+
P: 866
it's to complicated, isnt it? =(
i've tried to change the validation so it will be : only save the cols(3) that is not NULL.

[code=vb]If cboSales.Text = "" Then
MsgBox "Choose Sales No!"
Exit Sub
Else
With rs
.
.
.
.
I had just added Exit Sub. : )

Rey Sean
Jan 16 '08 #26

P: 44
I had just added Exit Sub. : )

Rey Sean
Dear Mr. Rey Sean,
Thanks for your reply, but it doesn't make any change, because what i want to validate is it msflexgrid of colums(3).
Jan 16 '08 #27

QVeen72
Expert 100+
P: 1,445
Hi,

Change the checking to :

If Val(MSFlexGrid1.TextMatrix(i, 3)) > 0 Then


Regards
Veena
Jan 16 '08 #28

P: 44
Hi,

Change the checking to :

If Val(MSFlexGrid1.TextMatrix(i, 3)) > 0 Then


Regards
Veena
I've change it and it works but it only save 1 itemdata instead of 5.
Do i need to make a looping? but how?
Jan 16 '08 #29

QVeen72
Expert 100+
P: 1,445
Hi,

Keep a BreakPoint on first line and debug,
and check if it passes through the"IF" condition and goes to ".AddNew" ..
(For all 5 rows)
If it is not passing, then the Value of the Grid for that row, is Blank/NIL

If it is passing, then PK has not been removed..


Regards
Veena
Jan 16 '08 #30

Post your reply

Sign in to post your reply or Sign up for a free account.