[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Duplicate Value Check in cxGrid!

Posted on 2006-11-28
7
Medium Priority
?
1,193 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

650 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