Topic: Question about two issues , Color tables and external options

Hey guys, i am still messing arround with MVDB and the questions i have is:

- Can i color a tablegrid line without displaying the item id in that tablegrid?

Example: i have an ID that goes from 1 to 5, 1 being green, 2 blue, 3 yellow, 4 orange, 5 red, But i don't want the table grid to show anything other than a name from another table.
Can i get a script to higlight that specific lines? i was able to do it, but i had to tell the tablegrid to show the id that defined the colors.


- Can i add an external txt for options?

If i wanted to add different users to determine some pre-settings , can i use something like an txt file that i can modify a line or something so i can get different results?

Eg. I have User 1, and he already has his name predefined when he creates a new worksheet, but i want user 2 to get access to the interface , but instead of having it predefined with user 1, i want to tell MVDB to go to an txt file, look at line 1 for instance, and if there's a 1, the combobox for the name is id=1, but if it's 2, the id=2 etc....

Can these be done?
Many thanks

Re: Question about two issues , Color tables and external options

1.


procedure Form1_TableGrid1_OnChange (Sender: string);
var
   i,c: integer;
begin
     Form1.TableGrid1.Columns.Count;
     c := Form1.TableGrid1.RowCount - 1;
     for i := 0 to c do
     begin
         if Form1.TableGrid1.dbIndexToID(i) = 1 then Form1.TableGrid1.Cell[0,i].Color := clGreen;
         if Form1.TableGrid1.dbIndexToID(i) = 2 then Form1.TableGrid1.Cell[0,i].Color := clBlue;
         if Form1.TableGrid1.dbIndexToID(i) = 3 then Form1.TableGrid1.Cell[0,i].Color := clYellow;
     end;
end;

about colors:

To specify any colour, you can use the number hexadecimal
Example: Form1.Label1.Font.Color := $00DDEEFF;
 where: FF - red, EE - green, DD - blue.

 In addition, you can use the text label colours
Example: Form1.Label1.Font.Color := clWindowText;
Example: Form1.Label1.Font.Color := clRed;

The following list the color constants:
 clBlack - Black
 clMaroon - Maroon
 clGreen - Green
 clOlive - Olive green
 clNavy - Navy blue
 clPurple - Purple
 clTeal - Teal
 clGray - Gray
 clSilver - Silver
 clRed - Red
 clLime - Lime green
 clYellow - Yellow
 clBlue - Blue
 clFuchsia - Fuchsia
 clAqua - Aqua
 clWhite - White


The list the colors that map to the closest matching color in the system palette:
 clDefault - The default color for the control to which the color is assigned.
 clActiveBorder - Current border color of the active window.
 clActiveCaption - Current color of the title bar of the active window.
 clAppWorkSpace - Current color of the application workspace.
 clBackground - Current background color of the Windows desktop.
 clBtnFace - Current color of a button face.
 clBtnHighlight - Current color of the highlighting on a button.
 clBtnShadow - Current color of a shadow cast by a button.
 clBtnText - Current color of text on a button.
 clCaptionText - Current color of the text on the title bar of the active window.
 clGradientActiveCaption - Windows 98 or Windows 2000: Right side color in the color gradient of an active window's title bar. clActiveCaption specifies the left side color.
 clGradientInactiveCaption - Windows 98 or Windows 2000: Right side color in the color gradient of an inactive window's title bar. clInactiveCaption specifies the left side color.
 clGrayText - Current color of text that is dimmed.
 clHighlight - Current background color of selected text.
 clHighlightText - Current color of selected text
 clHotLight
 clInactiveBorder - Current border color of inactive windows.
 clInactiveCaption - Current color of the title bar of inactive windows.
 clInactiveCaptionText - Current color of the text on the title bar of an inactive window.
 clInfoBk - Windows 95 or NT 4.0 only: Background color for tool tip controls.
 clInfoText - Windows 95 or NT 4.0 only: Text color for tool tip controls.
 clMenu - Current background color of menus.
 clMenuBar
 clMenuHighlight
 clMenuText - Current color of text on menus.
 clScrollBar - Current color for the of scroll bar track.
 cl3DDkShadow - Windows 95 or NT 4.0 only: Dark shadow for three-dimensional display elements.
 cl3DLight - Windows 95 or NT 4.0 only: Light color for three-dimensional display elements (for edges facing the light source).
 clWindow - Current background color of windows.
 clWindowFrame - Current color of window frames.
 clWindowText - Current color of text in windows.


2. You can use INI files and class TIniFile
Example, how to read from ini file

procedure Form1_OnShow (Sender: string; Action: string);
var
   ini: TIniFile;
   s: string;
begin
     ini := TiniFile.Create(ExtractFilePath(Application.ExeName) +'file.ini');
     s := ini.ReadString('SectionName1', 'ValueName1', '');
     ini.Free;
end;

Example of read file:

[SectionName1]
ValueName1=Hello
ValueName2=Bye
ValueName3=Thanks

[SectionName2]
ValueName1=bla bla
Dmitry.

Re: Question about two issues , Color tables and external options

Thanks Dmitry, i'll try it soon smile

Re: Question about two issues , Color tables and external options

hey Dmitry, i was able to get the ini file working, but i have a question with the colors:


Form1.TableGrid1.dbIndexToID(i) = 1 then Form1.TableGrid1.Cell[0,i].Color := clGreen;

In this case how do i point out that the id i want is on table1.id_2 ?

Re: Question about two issues , Color tables and external options

VascoMorais wrote:

hey Dmitry, i was able to get the ini file working, but i have a question with the colors:


Form1.TableGrid1.dbIndexToID(i) = 1 then Form1.TableGrid1.Cell[0,i].Color := clGreen;

In this case how do i point out that the id i want is on table1.id_2 ?

Just add field "id" to the TableGrid

Dmitry.