Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit u_combobox_sidecool;
- interface
- uses
- StdCtrls;
- type
- TString_ = class(TObject)
- private
- FStr: String;
- public
- constructor Create(const AStr: String);
- property
- Str: String read FStr write FStr;
- end;
- procedure AddItemComboBox(ComboBoxName: TCustomComboBox; Value: String; Key: String);
- function getComboBoxIndex(ComboBoxName: TCustomComboBox; Key: String): Integer;
- function getComboBoxKode(ComboBoxName: TCustomComboBox): String;
- function getComboBoxText(ComboBoxName: TCustomComboBox): String;
- implementation
- { TString_ }
- constructor TString_.Create(const AStr: String);
- begin
- inherited Create;
- FStr := AStr;
- end;
- procedure AddItemComboBox(ComboBoxName: TCustomComboBox; Value,
- Key: String);
- begin
- ComboBoxName.Items.AddObject(Value, TString_.Create(Key));
- end;
- function getComboBoxIndex(ComboBoxName: TCustomComboBox;
- Key: String): Integer;
- var
- i: Integer;
- begin
- i := 0;
- while i < ComboBoxName.Items.Count do
- begin
- if TString_(ComboBoxName.Items.Objects[i]).Str = Key then
- begin
- Result := i;
- end;
- i := i+1;
- end;
- end;
- function getComboBoxKode(ComboBoxName: TCustomComboBox): String;
- begin
- if ComboBoxName.ItemIndex >= 0 then
- Result := TString_(ComboBoxName.Items.Objects[ComboBoxName.ItemIndex]).Str;
- end;
- function getComboBoxText(ComboBoxName: TCustomComboBox): String;
- begin
- if ComboBoxName.ItemIndex >= 0 then
- Result := TComboBox(ComboBoxName).Text;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment