Board index » cppbuilder » How do you change dbGrid options at runtime

How do you change dbGrid options at runtime


2004-10-28 01:02:50 PM
cppbuilder22
I want to place a button on my form.
I want the button to allow me to change
the dbgrid options to what I wish after the
form is running. How do I do that?
 
 

Re:How do you change dbGrid options at runtime

As, you never spacify what you want to change, it's to broad to explain. I'd
suggest you read the full documentation of TDBGrid in the help files
provided by BCB.
Regards.
"Steve" < XXXX@XXXXX.COM >wrote in message
Quote

I want to place a button on my form.
I want the button to allow me to change
the dbgrid options to what I wish after the
form is running. How do I do that?
 

Re:How do you change dbGrid options at runtime

I would not be posting if I could find the answer in the help
or various books I have on borland products. Here is what I am doing, I set the grid to be non editable in the property sheet at design time. I load the same grid with different recordsets. Some I want to be able to edit at runtime, some not. I want to be able to change that after the grid loads, when I want to. I don't see why this should be so difficult, surely someone else has wanted to do this as well.
Thanks Steve
"Newsreader" < XXXX@XXXXX.COM >wrote:
Quote
As, you never spacify what you want to change, it's to broad to explain. I'd
suggest you read the full documentation of TDBGrid in the help files
provided by BCB.

Regards.

"Steve" < XXXX@XXXXX.COM >wrote in message
news:41807d7a$ XXXX@XXXXX.COM ...
>
>I want to place a button on my form.
>I want the button to allow me to change
>the dbgrid options to what I wish after the
>form is running. How do I do that?


 

{smallsort}

Re:How do you change dbGrid options at runtime

Quote
I want the button to allow me to change
the dbgrid options to what I wish after the
form is running. How do I do that?
DBGrid1->Options ?
 

Re:How do you change dbGrid options at runtime

We're a bit touchy (touched!?!) here in the BCB newsgroups - the best in the
world! So your flippant tone won't earn you any favours. However, I am in a
good mood today (though why is a complete mystery; I should be out
granny-bashing at the moment), so here is what I found in the BCB help file :-
TDBGrid has a property Options. One of these options controls the ability to
update records in the grid :-
dgEditing
true: (Default). Enables editing, inserting, and deleting records in the grid.
false: Disables editing, inserting, and deleting records in the grid.
So, disable editing by going
DBGrid1->Options=DBGrid1->Options>>dgEditing;
and enable it with
DBGrid1->Options=DBGrid1->Options<<dgEditing;
HTH
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
"Steve" < XXXX@XXXXX.COM >wrote in message
| I would not be posting if I could find the answer in the help
| or various books I have on borland products. Here is what I am doing, I set
the grid to be non editable in the property sheet at design time.I
| load the same grid with different recordsets. Some I want to be able to edit
at runtime, some not. I want to be able to change that after the
| grid loads, when I want to. I don't see why this should be so difficult,
surely someone else has wanted to do this as well.
 

Re:How do you change dbGrid options at runtime

Mark,
Thanks very much, that is what I was looking for, I could not find this anywhere. The prev answer did po me as if I could
find it in the help I would not have posted. Any where
I could read up on to really learn how to manipulate the
dbGrid? I would like to be able to do more with it.
Steve
"Mark Jacobs" <www.jacobsm.com/mjmsg?Borland%20Newsgroup>wrote:
Quote
We're a bit touchy (touched!?!) here in the BCB newsgroups - the best in the
world! So your flippant tone won't earn you any favours. However, I am in a
good mood today (though why is a complete mystery; I should be out
granny-bashing at the moment), so here is what I found in the BCB help file :-

TDBGrid has a property Options. One of these options controls the ability to
update records in the grid :-

dgEditing

true: (Default). Enables editing, inserting, and deleting records in the grid.
false: Disables editing, inserting, and deleting records in the grid.

So, disable editing by going

DBGrid1->Options=DBGrid1->Options>>dgEditing;

and enable it with


DBGrid1->Options=DBGrid1->Options<<dgEditing;

HTH
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk

"Steve" < XXXX@XXXXX.COM >wrote in message
news:4180e808$ XXXX@XXXXX.COM ...
| I would not be posting if I could find the answer in the help
| or various books I have on borland products. Here is what I am doing, I set
the grid to be non editable in the property sheet at design time.I
| load the same grid with different recordsets. Some I want to be able to edit
at runtime, some not. I want to be able to change that after the
| grid loads, when I want to. I don't see why this should be so difficult,
surely someone else has wanted to do this as well.


 

Re:How do you change dbGrid options at runtime

Well, to begin with, your first post never describe what you want to do,
it's hard for us to help you if we do not know what you are going to
attempt. That's why I suggest you to read the docs to find out more detail.
If you have stated you want to disable editing to the DBGrid in your first
post, surely I'd give you the answer. Well since I'm in a good mood (like
Mark :-)) and really want to help (that's why I'm reading the forum), I'll
throw in more details for you.
As you described in the 2nd letter, you want to enable editing in some
fields (Columns) of the DBGrid, while making others non-editable, here is
the answer:
DBGrid1->ReadOnly = false; //make sure the Grid is not ReadOnly
DBGrid1->Columns->Items[the index of fields you want to make
non-editable]->ReadOnly = true;
And no! you cannot reverse the logic by setting the DBGrid to ReadOnly and
set certain fields to ReadOnly = false. This won't work
Remember, always be more descriptive and ask the question in a precise way.
It's the first few rules of this newsgroup.
Regards.
"Steve " < XXXX@XXXXX.COM >wrote in message
Quote

Mark,

Thanks very much, that is what I was looking for, I could not find this
anywhere. The prev answer did po me as if I could
find it in the help I would not have posted. Any where
I could read up on to really learn how to manipulate the
dbGrid? I would like to be able to do more with it.
 

Re:How do you change dbGrid options at runtime

A good link for DBGrid stuff is delphi.about.com/b/a/027886.htm (Zarko
Gajic's site), but it is in Delphi. However, the function, event and property
names are usually the same as in BCB, so it should give you some pointers on
how to get the most out of DBGrid. Good luck,
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
"Steve " < XXXX@XXXXX.COM >wrote in message
| Thanks very much, that is what I was looking for, I could not find this
anywhere. The prev answer did po me as if I could
| find it in the help I would not have posted. Any where
| I could read up on to really learn how to manipulate the
| dbGrid? I would like to be able to do more with it.
 

Re:How do you change dbGrid options at runtime

Quote
I would not be posting if I could find the answer in the help
or various books I have on borland products. Here is what I am doing, I
set the grid to be non editable in the property sheet at design time. I load
the same grid with different recordsets. Some I want to be able to edit at
runtime, some not. I want to be able to change that after the grid loads,
when I want to. I don't see why this should be so difficult, surely someone
else has wanted to do this as well.
Quote

Options is a set. If you look for help on Sets, you will how to use the
>and << operators to change set items...
Lynn