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
Solved

Duplicate Value Check in cxGrid!

Posted on 2006-11-28
7
1,128 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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