Select dbgrid column cell by field name.
If next_not_visible variable is true then if a field is not visible next visible field selected.
1 |
<br /><br />procedure selectindexbyfield(grid_:TDBGrid;field_:string;next_not_visible:boolean);<br />var fn:integer;<br />begin<br />if lowercase(grid_.SelectedField.FieldName)=lowercase(field_) then exit;<br /><br />for fn:=0 to grid_.FieldCount-1 do if lowercase(grid_.Fields[fn].FieldName)=lowercase(field_) then break;<br /><br />grid_.SelectedIndex:=fn;<br /><br />if next_not_visible then<br /> while not grid_.Columns.Items[fn].Visible do begin<br /> inc(fn);<br /> grid_.SelectedIndex:=fn;<br /> if fn>grid_.FieldCount-1 then break;<br /> end;<br /><br />end;<br /><br /> |