|
-
October 20th, 1999, 03:26 AM
#1
Grid or Text Boxes ?
I want to create a table where the user can insert some values (nothing to do with database). Which is the better way to use: DBGrid (unbound mode) or many text boxes near to each other as a control array?
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 03:54 AM
#2
Re: Grid or Text Boxes ?
I'd use a DBGrid.
Why?
with textboxes you'd probably have to implement scrolling(keyboard AND mouse) very soon.
Even if your app has nothing to do with a database I'd still use bound mode and use a disconnected recordset (as I have been trying to advertise for many many months in this forum :-)).
-
October 20th, 1999, 04:04 AM
#3
How to?
Ok I'll try use your way. Can you tell me how to?
(although you may told me again but I don't remember...).
Have in mind that I want to satisfy these:
1. The user can delete any row, by selecting and pressing delete.
2. The user can add a row at the end.
3. The values that inserts on grid must be under some rules (I will build a knowledge based system-grid with many rules, checking and control)
Having all these in mind could you post the right code for it?
(The size of the grid will be at about 18 columns and 500 rows...)
Thank you Lothar!
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 04:28 AM
#4
Re: How to?
Unfortunately, I do not have the time to write your application :-)
requirements 1 and 2 are properties of the dbgrid. It's easy to set allowAddnew and allowdelete to true.
to implement validation logic you can do this in your save logic (probably triggered from a button or menu).
here is a small sample to use a dbgrid in bound mode without a database.
Dim r as ADOR.Recordset
set r = new ADOR.Recordset
r.Fields.Append "firstfield", adInteger
r.Fields.Append "secondfield", adInteger
r.CursorType = adOpenDynamic
r.Open
r.AddNew
r.Fields(0).Value = 1
r.Fields(1).Value = 2
r.AddNew
r.Fields(0).Value = 3
r.Fields(1).Value = 4
set g.DataSource = r
by setting AllowAddNew and AllowDelete to True, I was able to add new rows and delete selected rows.
This has been tested unter
NT4 SP 5
VB 6 SP3
Good luck.
-
October 20th, 1999, 04:29 AM
#5
Re: How to?
One more point. I didn't even have to add the complete ADO reference, but only the small ADOR recordset library!
-
October 20th, 1999, 05:04 AM
#6
Some corrections...
The right code sould be this:
Dim r as ADOR.Recordset
set r = new ADOR.Recordset
r.Fields.Append "firstfield", adInteger
r.Fields.Append "secondfield", adInteger
r.CursorType = adOpenDynamic
r.Open
r.AddNew
r.Fields(0).Value = 1
r.Fields(1).Value = 2
r.AddNew
r.Fields(0).Value = 3
r.Fields(1).Value = 4
set g = r.DataSource
Right? But what is g?
How to define it?
Thanx Lothar!!!
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 06:07 AM
#7
Re: Some corrections...
I don't see what makes you code "righter" than mine, since mine worked.
Anyway, "g" is the name of my dbgrid object on the form. I'm lazy, that's why all my controls have short names :-)
-
October 20th, 1999, 07:58 AM
#8
Re: Some corrections...
Only the last line of your code was inversed!
And this is not my code... All is yours!!!
So, thank you a lot.
Rating comes soon...
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 08:07 AM
#9
Is that right?
set DBGrid1 = r.DataSource
Are you sure? This doesn't work...
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 08:37 AM
#10
Re: Is that right?
I'm confused. I guess you are right.
-
October 20th, 1999, 08:58 AM
#11
OK I am right but how is the right code?
Please can you post me the right code, because I am very curious to explore your way...
It seems very simple to be true!!!
:-)
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 09:00 AM
#12
Re: OK I am right but how is the right code?
Set YourGridNameGoesHere.DataSource = r
should do it.
-
October 20th, 1999, 09:10 AM
#13
Still doesn't work...
It displays the following message:
"Class doesn't support Automation or does not support expected interface"
??? :-o
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
-
October 20th, 1999, 09:13 AM
#14
Re: Still doesn't work...
Looks like we are using different grids?!
I have already thrown away my sample project. Try using one of the grids that supports ADO data binding.
-
October 20th, 1999, 09:22 AM
#15
Still doesn't work...
I use:
Microsoft Data Bound Grid Control 5 (SP3). Is that the same with yours?
Yes, it has datasource property!
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
Athens, Greece
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|