Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

array of TMaskEdit visible at design time

Posted on 1999-07-26
10
Medium Priority
?
282 Views
Last Modified: 2010-04-04
I think I need a array of MaskEdit.  I now I can make it at runtime, but I need them visible at design time.

I want to make a procedure that look like this:
   procedure Tform1.button1Click(Sender: TObject);
   var i:integer;
   begin
     for i:=0 to 30 do
       Table1.FieldByNumber(i).value:=Maskedit[i].text;
   end;

Are there other solutions?

Is it possible to just use Maskedit1, Maskedit2, ... (not in an array of TMaskedit but individual components) and use a procedure with "for i:=0 to 30 do ..." so I can assign all the 30 values in one time to the table fields?

Please a short example of the procedure if this is possible.

All solutions welcome.

Thanks.

PS sorry for my poor English.
0
Comment
Question by:ka1a
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1391250
hi ka1a,

why do you use TMaskEdits you can also use a TDBField connected to a TField, which also provides a editmask and a displaymask.

meikl
0
 
LVL 17

Expert Comment

by:inthe
ID: 1391251
Hi
would somethinhg like this work:

procedure TForm1.Button1Click(Sender: TObject);
var
  i,ii : integer;
begin
ii:=1;
  for i := 0 to ComponentCount -1 do
    begin
      if( Components[i] is TMaskEdit )then
      begin
       Table1.FieldByNumber(ii).value:=Maskedit[i].text
       inc(ii);
      end;
  end;

Regards Barry
0
 

Author Comment

by:ka1a
ID: 1391252
Hello Meikl,

I was told that when I use TDBfield any changes I make immediatly will be saved into the file (table1).  When I made a mistake and the cursor leave the field the changes will be saved.  Or was I mis informt?  I need visible fields that be linked (or can be linked) to table1 fields but that not automatic save any changes that I made, unless I give the order to.  When I place the table1 fields on the form, all changes wille be saved automatic.

If this is not tru, please tell me.  Why make it difficult as it can be done easy.

Any suggestions?

Dirk.
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.

 

Author Comment

by:ka1a
ID: 1391253
Barry,

This could be a sollution but the problem is that I need to link the fields with the exact indexnumber.  When I use i and ii, I don't have any control to get the correct Maskedit field in the correct table1 field.

All suggestions welcome.

Dirk.
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1391254
Sounds like you need a property editor.
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1391255
Try this custom property editor. Create a property in your component (MyProperty). The functions below will allow you to pick from a list of items. The items can come from anywhere. (list.txt in this case.)

1. Override the base class items. TStringProperty in this case.

  type
    TEditProperty = class(TStringProperty)
      function GetAttributes:TPropertyAttributes;override;
      procedure GetValues(Proc:TGetStrProc);override;
  end;

2. Register your property editor.

procedure Register;
begin
RegisterComponents('Samples', [TMyComponent]);
RegisterPropertyEditor(TypeInfo(String), TMyComponent, 'MyProperty', TEditProperty);
end;

3. Add functions at the bottom of your component unit.  

  function TEditProperty.GetAttributes:TPropertyAttributes;
  begin
    Result:=[paValueList,paSortList]; // this is always the same. (for me anyway)
  end;

  procedure TEditProperty.GetValues(Proc:TGetStrProc);
  var
    i:integer;
  begin
    with TStringList.Create do
      begin
      LoadFromFile('list.txt'); <<< put your masks in here;
      for i:=0 to Count-1 do
        Proc(Strings[i]);  // this adds a list of items to pick from.
      Free;
      end;
  end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1391256
hi dirk,

>Or was I mis informt?
yes

the fields are stored in the table by the post-method, which affect the whole record. solong the record is not posted you can restore all fields with the cancel-method.

each tfield has an additional-property OldValue, which can be used to restore one Field.

last not least, no, if you leave a field, the value is not physically stored in the table.

an automatic-post appears if you leave the record, with for ex. the next-method.
but ttable provides a lot propertys (modified,state) and events (onBeforeScroll), where you can check and prevent this action, if it not allowed by yours.

meikl
0
 

Author Comment

by:ka1a
ID: 1391257
meikl,

Thanks.

How can I get the prommised points to you?

Dirk.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 80 total points
ID: 1391258
well dirk,

glad that i helped you
good luck

meikl ;-)
0
 

Author Comment

by:ka1a
ID: 1391259
Meikl,

Al work fine.  Except the fields where I put this editmask:
  DBEdit1.field.editmask:='!00/00/0099;1;_';

The input will be checked correctly but it seems that it's not possible to put blank dates in the database.  It always give the errormessage that it's not a valid date.  When the editmask is removed from the field it is possible to enter blank dates.

Any suggestions,
thanks,
Dirk.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

661 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