Solved

Checkbox to edit DBGrid - On check enable edit (read only mode = false)

Posted on 2004-09-09
14
510 Views
Last Modified: 2010-04-05
Like the subject says....can someone please show me the correct code to do this:

For TCheckBox: on check enable DBGrid1 edit mode (Read only set to false)

Thanks.
0
Comment
Question by:VirtueTech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
14 Comments
 
LVL 10

Assisted Solution

by:Jacco
Jacco earned 250 total points
ID: 12022972
This would be the way:

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  DBGrid1.ReadOnly := CheckBox1.Checked;
end;

Hook up the OnClick event of a TCheckBox to this code.

The use can still select text in columns but can't edit them when the CheckBox is checked.

Another way is

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then
    DBGrid1.Options := DBGrid1.Options + [dgRowSelect]
  else
    DBGrid1.Options := DBGrid1.Options - [dgRowSelect] + [dgEditing];
end;

(The help file says dgEditing is ignored when rowselect is True, but it is set to false in stead)

The effect is best seen if you set DBGrid.Options.AlwaysShowSelection to True as well

Regards Jacco
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12023672
another possibility would be to set this on the dataset direct like

begin
  dbgrid1.datasource.dataset.readonly := not checkbox1.checked;
  //checked-> edit allowed, unChecked= edit not allowed
  //if the other direction wished-> remove the not
end;

meikl ;-)
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 250 total points
ID: 12024768
or as he exactly asked:

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  DbGrid1.ReadOnly := not(TCheckBox(Sender).Checked);
end;

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:ThoseBug
ID: 12045574
May be you need checkbox into dbgrid?...i field with boolean values shows like tcheckbox?
0
 

Author Comment

by:VirtueTech
ID: 12055383
Sorry for not replying...thank you everyone for your answers. I'm going to try them out now.
0
 

Author Comment

by:VirtueTech
ID: 12060910
Thanks everyone for your time.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12061437
? did not jacco give this suggestion (the graded answer) first ?
0
 
LVL 10

Expert Comment

by:Jacco
ID: 12061482
Yeah, well I forgot the not...
0
 

Author Comment

by:VirtueTech
ID: 12066029
Sorry I'm new to this....am I supposed to "split the points"?  If so how...I don't see an option for that. I just read about it but...

0
 

Author Comment

by:VirtueTech
ID: 12066865
Ok...Kretzschmar...unaccept it for me please.

Also...what would be the proper split of points. Give the user Jacco more points? Or give them both equal?

Thanks for your time.
0
 

Author Comment

by:VirtueTech
ID: 12067408
Thanks...just wanted to get an idea of how a proficient EX-EX user used the "split points" procuedure.

0
 
LVL 10

Expert Comment

by:Jacco
ID: 12069733
Thanks VirtueTech!
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month6 days, 15 hours left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question