TDBLookupCombobox determining the rows for certain dropdownlist height

Hi,
In the past, if I remember right, I had see a code snippet for calculating 
the number of the TDBcombobox 's dropdownrows for a certain height of the 
dropdown list.
Has anyone a similar code to share with me please ?
thnks in advance
0
Papas
8/15/2015 7:53:46 PM
embarcadero.delphi.vcl.using 2297 articles. 1 followers. Follow

9 Replies
293 Views

Similar Articles

[PageSpeed] 48

Papas Jim wrote:

> Hi,
> In the past, if I remember right, I had see a code snippet for
> calculating the number of the TDBcombobox 's dropdownrows for a
> certain height of the dropdown list.
> Has anyone a similar code to share with me please ?
> thnks in advance

var
  r: TRect; 

   DBComboBox1.Perform(CB_GETDROPPEDCONTROLRECT,0,longint(@r));

might work, but only if the combobox is already dropped down. 




-- 
Peter Below (TeamB)
0
Peter
8/17/2015 7:22:43 PM
Hi Peter,
unfortunately doesn't work, maybe because you use a DBcombobox not a 
DBLookupCombobox as I want
I tried it in OnDropDown and OnCloseUp events but r returns unchanged.
I tried h := DBLookupComboBox1.Perform(CB_ITEMHEIGHT,0,0);  but nothing 
again
any suggestions please ?
0
Papas
8/18/2015 9:22:56 AM
Hi Peter,
unfortunately doesn't work, maybe because you use a DBcombobox not a 
DBLookupCombobox as I want
I tried it in OnDropDown and OnCloseUp events but r returns unchanged.
I tried h := DBLookupComboBox1.Perform(CB_ITEMHEIGHT,0,0);  but nothing 
again
any suggestions please ?
0
Papas
8/18/2015 9:24:42 AM
Hi Peter,
unfortunately doesn't work, maybe because you use a DBcombobox not a 
DBLookupCombobox as I want
I tried it in OnDropDown and OnCloseUp events but r returns unchanged.
I tried h := DBLookupComboBox1.Perform(CB_ITEMHEIGHT,0,0);  but nothing 
again
any suggestions please ?
0
Papas
8/18/2015 9:28:40 AM
Papas Jim wrote:

> Hi Peter,
> unfortunately doesn't work, maybe because you use a DBcombobox not a 
> DBLookupCombobox as I want
> I tried it in OnDropDown and OnCloseUp events but r returns unchanged.
> I tried h := DBLookupComboBox1.Perform(CB_ITEMHEIGHT,0,0);  but
> nothing again
> any suggestions please ?

Why not:

{code}
  dbComboBox1.DropDownCount:=65 div dbComboBox1.ItemHeight;
{code}

as far as I can tell when you change the font of the combobox the
itemheigt is calculated correctly.
0
Lajos
8/18/2015 12:31:28 PM
Papas Jim wrote:

> Hi Peter,
> unfortunately doesn't work, maybe because you use a DBcombobox not a 
> DBLookupCombobox as I want
> I tried it in OnDropDown and OnCloseUp events but r returns unchanged.
> I tried h := DBLookupComboBox1.Perform(CB_ITEMHEIGHT,0,0);  but
> nothing again
> any suggestions please ?

Why not:

{code}
  dbComboBox1.DropDownCount:=65 div dbComboBox1.ItemHeight;
{code}

as far as I can tell when you change the font of the combobox the
itemheigt is calculated correctly.
0
Lajos
8/18/2015 1:53:17 PM
Papas Jim wrote:

> Hi Peter,
> unfortunately doesn't work, maybe because you use a DBcombobox not a 
> DBLookupCombobox as I want
> I tried it in OnDropDown and OnCloseUp events but r returns unchanged.
> I tried h := DBLookupComboBox1.Perform(CB_ITEMHEIGHT,0,0);  but
> nothing again
> any suggestions please ?

Ah yes, the TDBLookupCombobox is not derived from TCombobox, it is a
VCL control that uses a TDBGrid for the dropdown part, if I remember
correctly. I somehow missed the Lookup part...

var
  LList: TPopupDataList;

if (dblookupcombobox1.ComponentCount > 0) and 
   (dblookupcombobox1.Components[0] is TPopupDataList)
then begin
  LList:= TPopupDatalist(dblookupcombobox1.Components[0] );
  ... LList.Rowcount gives the number of visible rows,
LList.ClientHeight the height of the client area,
      LList.Font the font used to render the items.
end;
   

-- 
Peter Below (TeamB)
0
Peter
8/18/2015 6:35:41 PM
"Peter Below"  wrote in message news:729871@forums.embarcadero.com... 

var
  LList: TPopupDataList;

if (dblookupcombobox1.ComponentCount > 0) and 
   (dblookupcombobox1.Components[0] is TPopupDataList)
then begin
  LList:= TPopupDatalist(dblookupcombobox1.Components[0] );
  ... LList.Rowcount gives the number of visible rows,
LList.ClientHeight the height of the client area,
      LList.Font the font used to render the items.
end;


Yes !
this works except that needs Components[1] 

Many thanks Peter !
0
Papas
8/18/2015 7:42:22 PM
So, for anybody who wants the dropdownList of a TDBLookupCombobox to display 
as many as possible items the code could be :

function dropDownItemHeight : integer;
var I : integer;
begin
    for i := 0 to DBSoftLookupComboBox1.ComponentCount-1 do
    if DBSoftLookupComboBox1.Components[i] is TPopupDataList
    then with TPopupDataList(DBSoftLookupComboBox1.Components[i]) do
    result:= ClientHeight div Rowcount;
end;
......
procedure TForm1.DBSoftLookupComboBox1DropDown(Sender: TObject);
var h : integer;
    p : TPoint;
begin
    with DBSoftLookupComboBox1 do
    p := self.ScreenToClient(parent.ClientToScreen(point(left,top)));
    h := self.ClientHeight - p.y - DBSoftLookupComboBox1.Height;
    DBSoftLookupComboBox1.DropDownRows := h div dropDownItemHeight;
end;

Thanks to Peter Below
0
Papas
8/18/2015 8:17:40 PM
Reply:

Similar Artilces:

get the row element values using row index for dynamic dropdownlist using javascript
Friends,How to get the row element values using row index for dynamic dropdownlist using javascript ?Thanks in advance  I want creating dynamic dropdownlist  using javascript. I am working on deleting a row. function DeleteRow(r) { var i = r.parentNode.parentNode.rowIndex;document.getElementById("ctl_Contentmain_tbldynamic").deleteRow(i);var str = document.getElementByName("ddljobs");   alert(str); } Check out this. var str = document.getElementById('<%=ddljobs.ClientID%>');   Thanks,santosh_maharajaPlease mark as answer ...

Same row height on all fields in row with autosize height
Hi! I have DW where one field is AutosizeHeight and Detail Band is also Autosize Height. Problem is that other fields in the same row are not the same height as this column. Is it posible to have all columns in row the same height? regards Tomaz What I do is setting an expresion in the Height property from all fields: RowHeight() - 8 "Tomaz Kralj" <tomaz.kralj@fibran.si> escribi� en el mensaje news:46149317$1@forums-1-dub... > Hi! > > I have DW where one field is AutosizeHeight and Detail Band is also > Autosize Height. Problem is tha...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

Display a certain row in a dropdownlist
I have a dropdownlist which displays dates for each Monday in the year. It has dates in the past and the future. When my page opens how can I always have it display Monday's date for the current week. TIA You can calculate which monday you need, then use dropdown.selectedIndex = <number> or dropdown.selectedItem = "Monday, 5th August" to make it load on that item.Intelligence is a burden.Jagdip Singh AjimalManchester (and yes, I am a Manchester United fan) I tried Me.WCommCbo.SelectedItem = "Monday 11th August" and it is underlined in blue. If I h...

Using PageTemplate to have a row used to add new rows to the datasource
I read in the Programming Microsoft ASP.NET 2.0 book that you can use the PagerTemplate to have an "extra" row used to add new rows to the datasource bound to the GridView.  Unfortuantely, it does not show how. I am trying to do this and I am having a problem where the Pager row is not showing up. I have defined a template:<PagerTemplate> <table width="100%"> <tr> <td><asp:LinkButton ID="btnAddFMEff" runat="server" Text="Add" CommandName="Add" /></td> <td style="width: 80%;"><asp:TextBox ID="txtNewEffect" runat="se...

Row height when using the CalendarExtender
I have a gridview within an updatepanel. I am use edit templates to allow users to modify the data. I'd like the use the CalendarExtender for choosing dates. This worked fine before I went to the edit template. Without the template, opening the calendar would cause the gridview row to expand to fit the actual calendar. But, with the template, the row doesn't expand. Everything in the calendar just get garbled up all over the page. Is there a way to make this thing work within an edit template?  Thanks! Can you post the code, so it will help Chetan SarodeSoftware Engineer,Appr...

force Delphi to use a certain component
Hello, I have a png component I want to use it to load png images but I have another third party tool also has a png unit the problem when I try to load a png image in an image box component , Delphi always uses the third party unit be default is there a way to change that without removing the third part components ? thanks On Wed, 28 Jan 2009 12:17:44 -0800, isaac sam wrote: > Hello, > I have a png component I want to use it to load png images but I have > another third party tool also has a png unit > > the problem when I try to load a png image in an ...

Dropdownlist to appear on certain rows in GridView
Hi all, I have a gridview that contain a number of rows. For a particular column in the gridview called "Dose", I would like it to be a dropdownlist for users to select dosage values. However, this dropdownlist is to only appear on certain rows and not every row, as its appearance depends on the type of medication. Thus, what would be an approach to this? I have searched for quite a while but have yet to come up with a solution. Thanks in advance,David K  Add a "TemplateColumn" and put a DropDownList in there and put the values in there (1,2,3,4 whatever you want). The...

Insert rows multiple times using a DropDownList
Hi all, The page I am working on at the moment allows the user to insert a book into the database. I am using ASP.NET VB and Access 2003 database. So far so good I can add a book to the database with no problems. However I have this drop down list which contains 10 list items numbered 1 to 10. The idea was that upon selecting an item from the drop down list the insert statement would be repeated that many times. For example if 5 was selected from the drop down list the record would be inserted into the database 5 times into tblBook. I have tried solving the problem using a F...

Spreadsheet component for use in Delphi VCL 2010
Good day I have been using the Flexcel component for reading and writing Excel spreadsheets in my Delphi VCL projects for some while and have been very happy. Unfortunately, though, a version for use with Excel 2007 format files (.XLSX) has been promised for years now but just never arrives and I have reached a stage where I just have to update some of my software. Can any body suggest alternatives and comment on their experience with these? I have no objection to buying a component although all my programs are for academic use by myself and colleagues/friends so cheaper would...

Delphi XE8 Send Notification from Parse using VCL app
Hello, I am learning the new Baas technology with XE8. I created a small app to receive notification on Android mobiles using Parse. Everything is working fine when the notification message is sent from Parse web site. However when my VCL app send the notification with BackendPush component, nothing is coming in mobile phone. The messages are sending correctly because I can see them on Parse site. Their status is different than the one sent from Parse . Here are my VCL messages Status on Parse: Type: API, target: Chanels. When sent on Parse site: Type : Campaign, Target: Everyone...

Delphi 6
In preparation for applying a bug fix to one of the VCL modules (AxCtrls.pas), I have been trying to compile the original source code for the module in order to reproduce exactly the existing dcu. I have copied AxCtrls.pas to an empty directory, and have found that doing: dcc32 -q AxCtrls -$D- -$L- gives me a dcu which is identical in size to the one on Delphi6/Lib, with identical contents except for a few bytes near the beginning, which I assume are a compliation timestamp. However, I have been unsuccessful in duplicating the debug dcu in Delphi6/Lib/Debug. Using "-$D+ -$L+&q...

Add New Row To DataGrid Using the Footer With a DropDownList Control
I am trying to discover the best method for adding a new row of data to a datagrid. My datagrid is bound to an SQL Server table. I was reading the article "Adding a New Record to the Datagrid", by John Sanborn (4GuysFromRolla.com) wherein he suggests a method of using the datagrid's footer for adding new records. The concept works if each column of data is to be keyed in by the user, but I have a requirement to provide a drop-down list of valid values for a specific column. I've been tinkering with using a drop-down list in the footer of the grid, but I am unable get it to displ...

Actuall thread about vcl classes / components in C++ for use with delphi...
Hi All, I wanted to follow the topic that appears as a 'sub-thread' above... suspecting it would die... I'm sure many of us are interested in this topic. ( by 'sure' I mean absolutely certain...) It also brings to my mind the question, does anyone know of any references for us semi-delphi-literate C++ programmers that would like to read/write/modify delphi stuff? Thanks Everyone, (you know who you are... B) Bruce ...