APS NZ
asked on
Multiselect in a TDBGrid
I am using D1 and WIN 3.11
I want to derive a component from TDBGrid so that the user can select more than one record. I am almost there, but my problem is that the whole row gets highlighted, not just the cell(s) within the column that the user selects.
Here is a code snippet from my component:
If (FindRecordNumber >= FRangeStart) And (FindRecordNumber <= FRangeEnd) then
If SelectedField = HighLightedField then
If SelectedIndex = Col-1 then
begin
Colour := Canvas.Brush.Color;
Canvas.Brush.Color := ClGreen;
Canvas.TextRect(Rect,Rect. Left+2,Rec t.Top+2,Fi eld.AsStri ng);
Canvas.Brush.Color := Colour;
end;
I probably got a bit carried away with my If statements, but I was trying to cover everything.
I want to derive a component from TDBGrid so that the user can select more than one record. I am almost there, but my problem is that the whole row gets highlighted, not just the cell(s) within the column that the user selects.
Here is a code snippet from my component:
If (FindRecordNumber >= FRangeStart) And (FindRecordNumber <= FRangeEnd) then
If SelectedField = HighLightedField then
If SelectedIndex = Col-1 then
begin
Colour := Canvas.Brush.Color;
Canvas.Brush.Color := ClGreen;
Canvas.TextRect(Rect,Rect.
Canvas.Brush.Color := Colour;
end;
I probably got a bit carried away with my If statements, but I was trying to cover everything.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Mmmmm....
ASKER
Hi ZifNab - Mmmmmm indeed. After a lot of experimenting I have now decided that I will have to just highlight the first and last items of the requested block within the column
That at least works properly. I still can't stop the Invalidating when I try to highlight all the required records.
That at least works properly. I still can't stop the Invalidating when I try to highlight all the required records.
jdthedj,
I soon have to make an adhanced dbgrid too. I'll try to make what you want too.
I soon have to make an adhanced dbgrid too. I'll try to make what you want too.
ASKER
Thanks ZifNab!!
ASKER
the system locks up unless I click an adjacent column. If I don't call Invalidate, the highlighting disappears as soon as I release the shift key.