Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DbGrid control Unbound Mode

Status
Not open for further replies.

cyberbiker

Programmer
Mar 16, 2001
431
0
0
US
It has been a very long time since I worked with the DBGrid control and I could use some help.

I need to use the control in the unbound mode.

Does any one happen to remember how to address a given cell.

Ie: set column 0 row 3 = somevalue.

Thanks

Terry (cyberbiker)
 
I did a little tinkering around, and the answer is (e. g.)
Code:
myDBGrid.Columns(intSomeColNo).Value = "SomeValue"

HTH

Bob
 
Very much so.

I did discover I had to specify the row first.

I left the code at work but I think it was something like

DbGrid1.row = (SomeInteger)
then your code.

Thanks a lot

Terry (cyberbiker)
 
I have been experimenting with this and still have 2 problems.

I can fill each column fine as Bob showed.

But when I try to add a second row, I overwrite the columns in the first row.

I just cannot seem to add a second row (etc) through code.

Additionally, I cannot clear the grid though code.

Any ideas?

Terry (cyberbiker)
 
Thanks Bob,

I am looking at it now and experimenting to see if it gives me what I want.



Terry (cyberbiker)
 
Keep us posted...I think those events are necessary, though.
 
I have been swamped today with unrelated issues so am really just starting with this.

I am uncertain if I am even going about this in the right way.

Simply put, I am developing an application where either they scan a bar code or enter a part number manually.

I want to display this data, permit the user to edit the quantity in column 0 the update a transaction table from the grid
with DBGrid1
.Columns(1) = rs("CustomerNumber")
.Columns(2) = rs("number")
.Columns(3) = rs("code")
end with

Permits me to fill each column properly but I can only fill row 0. I cannot seem to move to row 1 (or a small, but unknown number of rows)

Once the user enters a quantity (column(0) of the dbgrid), I then write to a transaction table.

I will let you know what I work out but if you have any ideas, I would appreciate them.

I am beyond frazzled right now I am afraid.



Terry (cyberbiker)
 
First off, I assume that you have some reason more compelling than its ability to work unbound? If not, there are alterantives that are more current.

Bob
 
I've not used DBGrid however think it is probably similar to the even older Grid control.

Think you'll find that you have to specify column and/or row any time you want to change either, thus

DbGrid1.row = 1
DbGrid1.column=1
DbGrid1.Text = "Have"

DbGrid1.row = 1
DbGrid1.column=2
DbGrid1.Text = "a"

DbGrid1.row = 2
DbGrid1.column=1
DbGrid1.Text = "good"

DbGrid1.row = 2
DbGrid1.column=2
DbGrid1.Text = "day"


HTH Hugh,
 
Further to my previous;

1. replace column with col.
2. it is possible to shorten the code a little

thus;

DbGrid1.row = 1
DbGrid1.col = 1
DbGrid1.Text = "Have"

DbGrid1.col = 2
DbGrid1.Text = "a"

DbGrid1.row = 2
DbGrid1.col = 1
DbGrid1.Text = "good"

DbGrid1.col = 2
DbGrid1.Text = "day"

Hugh,
 
Bob, I need the ability to work unbound and edit the grid directly which is why I chose DBrid control.

I may need to choose a different method though. I am thinking of just adding text boxes at run time and "faking" a grid.

Hugh,
This line fails for me when maxrow is not 0.

DBgrid1.row = maxrow

Error is the user defined or application error



Terry (cyberbiker)
 
Oops that was application defined or Object defined error

Terry (cyberbiker)
 
This may clear up my problem a bit.

I need to read 1 record from an inventory table
display that record
read another record
display that along with the first

and so on and so on

Each record is selected according to a unique key in the database

The user may then edit the quantity column and write to a transaction table "line item by line Item"

I could perhaps try using a listview control with a popup that the user can enter the quantity.

I prefer not to use the MSFLEX grid with text boxes since I never seem able to exactly align the text boxes to the grid

Terry (cyberbiker)
 
I did just discovered that I can edit the list View control with 2 single clicks on the item (qty)

That is much better for my needs.

I did put in the pop up as well if they double click which should make everybody happy



Terry (cyberbiker)
 
I truly appreciate your help on this. I learned a lot (mostly what not to try). I used DBgrid several years ago in bound mode and it worked quite well for those apps.

I realize I could use it in unbound mode as well, but, as it turned out, not for this situation unless I used a UNION query as the recordset.

Since I am using a non microsoft database with a limit on the number of UNIONS, I would be limited as to the total number of items. Unacceptable so I could not go that way.

And the end users seem to like the ability to either edit directly or through an input box so I think I am coming out smelling like a rose this time

Terry (cyberbiker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top