Home Using TcxPopUpEdit
Reply: 2

Using TcxPopUpEdit

userhi
1#
userhi Published in 2017-11-11 07:42:58Z

I have tried using a cxGrid and TcxPopEdit to create a checkedComboBox, and I implemented to check each checkbox in the list and show the checked value in PopupEdit.

For extending it a bit, I had added a PopupMenu for the GridView.

Now , there are two buttons say Select all , Clear all on popupmenu, When i rightclick the gridview and say selectall it should check all the checkboxes and when i say clear all it should uncheck all checkboxes.

Can anyone please suggest me some idea for achieving this? By the way we are using Dev Express 5.15(Express QuantumGrid v5.15 etc..) with Borland Delphi 6 as Development IDE.

I am attaching a screenshot of how my app looks. Here is the Source which i implemented for doing this Get the Sample Project from DropBox. SampleProject

MartynA
2#
MartynA Reply to 2017-11-11 11:25:05Z

The code below will set or clear the checkboxes associated with a field called 'Marked' in the dataset connected to your grid's datasource. If that is not what you are trying to do, you need to be more specific in your q.

procedure TForm1.ProcessCheckboxes(SetCB : Boolean);
var
  ADataSet : TDataSet;
  BM : TBookmark;
  Field : TField;
begin
  ADataSet := DataSource1.DataSet;
  Field := ADataSet.FieldByName('Marked')
  BM := ADataSet.GetBookmark;  //  Place a bookmark on the dataset so that the
  //  same row stays current
  try
    ADataSet.DisableControls;  //  temporarily prevent the grid from being updated on-screen
    ADataSet.First;
    while not ADataSet.Eof do begin
      ADataSet.Edit;
      if SetCB then
        Field.Value := True
      else
        Field.Value := False;
      ADataSet.Post;
      ADataSet.Next;
    end;
  finally
    ADataSet.GoToBookMark(BM);  //  go back to the row where we placed the bookmark
    ADataSet.FreeBookMark(BM);
    ADataSet.EnableControls;
  end;
end;
Aqil
3#
Aqil Reply to 2017-11-11 22:38:21Z

Base on your project code, i write some code that are very close to @MartynA answer, but base on your codes.I did not test them but the main logic for your needs is in both answer. for do this you have to change data not change component property directly.

procedure TfrmCXPopUpEdit.CheckAll1Click(Sender: TObject);
Var
  ADataSet : TDataSet;
  bm : TBookmark;
begin
    bm := CDS_LookUp.GetBookmark;
    CDS_LookUp.DisableControls;
    CDS_LookUp.first;
    while  not CDS_LookUp.eof do
    begin
        CDS_LookUp.edit;
        CDS_LookUpDBFLAG.AsBoolean := true;
        CDS_LookUp.post;
        CDS_LookUp.next;
    end;
    CDS_LookUp.GoToBookMark(bm); 
    CDS_LookUp.FreeBookMark(bm);
    CDS_LookUp.EnableControls;
end;

procedure TfrmCXPopUpEdit.ClearAll1Click(Sender: TObject);
Var
  ADataSet : TDataSet;
  bm : TBookmark;
begin
    bm := CDS_LookUp.GetBookmark;
    CDS_LookUp.DisableControls;
    CDS_LookUp.first;
    while  not CDS_LookUp.eof do
    begin
        CDS_LookUp.edit;
        CDS_LookUpDBFLAG.AsBoolean := false;
        CDS_LookUp.post;
        CDS_LookUp.next;
    end;
    CDS_LookUp.GoToBookMark(bm);  
    CDS_LookUp.FreeBookMark(bm);
    CDS_LookUp.EnableControls;
end;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336943 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO