Hello,

I was wondering if there is a way to remove the first empty entry in the drop-down box when editing a cell that is in a column with relationship to a different table (foreign key)?

Similar to the ComboBox component which one can change "FirstEmptyItem" to true or false - in this case, I would like it to be false.

I am currently using .dbListFields method. However, even when I tried generating the grid using the friendly UI, my table fields are set to 'Not null' with a default value, I still get a blank entry at the top.

Additionally it would also be great if when editing the cell, the drop-down selection will be on the already set value - is there a way to do that also?

As always, thank you in advance for any help!

Hello,

I was wondering if there is an in-line TableGrid edit method so that I can trigger a selected cell to go into edit mode?

Obviously, using the mouse double click allows you to enter edit mode of a cell but how does one do so using just a keyboard?

Further more, it is common that the F2 key or, in some cases, Shift+F6 keyboard shortcuts allows you to enter edit mode of a cell which is what I am trying to achieve.

I know I can do:

procedure Form1_TableGrid_OnKeyUp (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
  begin
    if Key = 71  then // 71 is key code for F2
      <ENTER SELECTED CELL EDIT MODE>
  end;

but as you can see I am missing the <ENTER SELECTED CELL EDIT MODE> part...

Any help or ideas will be appreciated and thank you in advance!

3

(4 replies, posted in Script)

You are correct! (obviously cool )

I was missing a parameter (position - crLast in my case) and it works!

Form1.TableGrid1.Columns.InsertTreeColumn(0);
Form1.TableGrid1.AddRow(1);
Form1.TableGrid1.AddChildRow(0,crLast);

Thanks again!

4

(4 replies, posted in Script)

Hi Sparrow!

As always, thank you so much for your help!

I was testing what you said but from my tests the AddChildRow is a TreeView only method so I get an error when I use it in a Table Grid component.

Is there a different way to indicate an added row is a child of a row in a Table Grid component (when utilizing the InsertTreeColumn)?

Thank you again!

5

(4 replies, posted in Script)

Hello fellow MVD users!

I read in the help files that the Grid component has the option to add a Tree column to it:

Form1.grid.InsertTreeColumn(0);

However there isn't more information of how can one tell it which column is the one that holds the hierarchy (ParentID) or if there needs to be some loop involved how to tell it that a row is a child of another row etc.

Does anybody know how to do so?

I ask because the TreeView component itself is a bit limited with how the "in-line" editing works (no dropdowns for cells etc.) nor can I manually "feed" it SQL like I can do with the Grid component by utilizing dbSQL.

As always thank you in advance for your time!

Sparrow!

Thank you so much for all the examples, they are very clear and I appreciate you for taking your time providing them, it really helps to learn - you are always a savior!

Hello,

When using the program's "built-in" dialogs to populate the grid component with data, we get drop-down boxes for each cell where foreign keys are present, allowing us to select values from related tables when creating or editing records.

However, when I populate the grid using an SQL query, these drop-down boxes do not appear.

Is there a way to replicate this behavior when using the SQL Query approach?

Thank you for your time!

sparrow, thank you so much for the prompt help!

As for the HTTPGet etc. error, I think I found the same post that you did which indicates that it's a port/proxy issue however I don't use a proxy nor do I use VPN etc. and so far the issue is only for the specific site I mentioned, not others.

I went with the WinHttp option since it's seems what was recommended as an alternative and it worked without any issues - i couldn't find any downside for using it and perhaps it is even more "future proof".

Thank you again, I managed to use the method you mentioned to download binary files without any issues!

Hello,

I was trying to download a file from a website mobygames using HTTPGet or HTTPGetFiles however it gives me an error (see error below) which I suspect maybe it's because the DLL's (libssl32 and libeay32) are too old (version 1.0.2)? - oddly it doesn't happen with other sites I tested.

So I opted to using WinHTTPReq that I found people suggest while searching the forum and it works without any issues for HTML pages but I am unsure how to download an image or any kind of a binary file (I tried adding an example link but the forum won't let me).

Can anyone please advise as to how to achieve it? (if it's even possible).

Any input would be highly appreciated and thank you in advance!

Update: I see that the attachment wasn't added so what the error says is:
Error connecting with SSL.
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

Thank you sparrow for your prompt reply and help!

Per your recommendation, I ended up hiding all of the current menu items (oddly that := nil didn't work for me, but I used the .Visible) and created a new menu which I triggered to show on right click using GetCursorPos and .Popup.

Just to note that the problem I was facing when I initially created this post still exists - using the existing context menu wasn't an option. The existing menu triggers before the OnMouseUp event of the grid which means anything I place to change the existing menu - Enable, Visible etc. - will only run after the menu shows (essentially the update will always be in on click delay).

But! as long as there is another way to achieve it, it is great!

Thank you again!

Hello,

I have been testing out this software and so far it is brilliant!

However, I have encountered a problem that I am unsure how to solve and would like to know if there is any solution, perhaps I am doing something wrong? (I am new to Pascal).

In summary: I think when you right-click on a grid row, the SelectedCount gets updated after the actions of OnMouseUp/OnMouseDown  which means one can't utilize the count for changing items in the menu.

A little bit in depth: I have a grid with some rows and a custom popup menu. The menu is defined as a separate procedure and gets to run every time there is either OnChange and OnMouseUp/OnMouseDown event.

Something like (simplified):

PopupMenuItem := TMenuItem.Create (PopupMenu);
PopupMenuItem .Caption := 'Always Visible';
PopupMenuItem .OnClick := @proc1;
PopupMenu.Items.Add(PopupMenuItem);

if (form.grid.SelectedCount > 0) and (form.grid.RowCount > 0) then
begin
  PopupMenuItem := TMenuItem.Create (PopupMenu);
  PopupMenuItem .Caption := 'Remove Selected';
  PopupMenuItem .OnClick := @proc2;
  PopupMenu.Items.Add(PopupMenuItem);
end;

if form.grid.RowCount > 0 then
begin
  PopupMenuItem := TMenuItem.Create (PopupMenu);
  PopupMenuItem .Caption := 'Remove All';
  PopupMenuItem .OnClick := @proc3;
  PopupMenu.Items.Add(PopupMenuItem );

The problem: upon first load of the GUI when nothing is selected in the grid, if you right-click on one of the rows, the menu that shows will not show "Remove Selected", only upon a second mouse click it will show it. As I explained, with my tests I think the SelectedCount is updated after the actions of actions of OnMouseUp/OnMouseDown.

I also tried the OnClick/OnCellClick events but from what I tested they only get triggered upon a left-click and not right-click.

Is there anyway to solve this? perhaps a better approach to all of this "custom popup menu" since one must also consider keyboard input etc.?

Any input would be much appreciate - thank you in advance!

SandBird