Solved

Duplicate Value Check in cxGrid!

Posted on 2006-11-28
7
1,113 Views
Last Modified: 2011-09-20
Dear Sir,
  My name is Daniel, from Taiwan. I have a little problem and need for your assists!
  How to check the data in cxGrid are all unique during data input?
  I was using TDBGrid before and did the check like this:

  procedure TDataModuleLcEntry1.QueryLc12ORDNOChange(Sender: TField);
  begin
    if CheckDup(QueryLc12ORDNO.AsString) then
    begin
      // go further
    end
    else
    begin
      ShowMessage('ORDER NO. Duplicate, Please input again!');
    end;
  end;

  function TDataModuleLcEntry1.CheckDup(myOrd: string): boolean;
  var
    V: Variant;
  begin
    V := QueryLc12.Lookup('ORDNO', myOrd, 'ORDNO');
    Result := (VarType(V) in [varNull]);
  end;

  This dosen't work with cxGrid, the ORDNO Column in cxGrid will all became the value as myOrd! don't know why!
  My English is not very well, hope you can understand what I am asking! Thanks for your help!
 
  Daniel
0
Comment
Question by:daniel710624
  • 3
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 18043683
maybe you could use a secondary query instead the lookup-method? possible for you?

meikl ;-)
0
 

Author Comment

by:daniel710624
ID: 18052046
Thanks for your help! But I can't use secondary query to instead, because of data haven't applied to database!
User can input many rows of data, than execute ApplyUpdates! Secondary query can't be my choice!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 18052071
in case of cachedupdates u cannot use a secondary query, thats true

thinking . . .
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:daniel710624
ID: 18135622
Still waiting for help! Thanks!
0
 

Author Comment

by:daniel710624
ID: 19271767
I found a way, but don't know if there is any better way?
Any one could help me out with this?

procedure TFormBaseGridEntry1.CheckKeyDup(KeyCol: word; Key1, Key1Label: String);
var
  i, x: Integer;
begin
  x := cxGridMasterView1.DataController.FocusedRowIndex;
  for i := 0 to cxGridMasterView1.viewdata.RowCount - 1 do
  begin
    if cxGridMasterView1.ViewData.Rows[i].Index = x then Continue;
    if Trim(cxGridMasterView1.ViewData.Rows[i].Values[KeyCol]) = Key1 then
    begin
      RepeatWarning(Key1Label);
      cxGridMasterView1.Controller.FocusedItemIndex := KeyCol;
      Abort;
    end;
  end;
end;
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21135793
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now