473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

topmost item in listbox

How do I get the index of the first displayed item in list box / combo box?
Thank you
Nov 17 '05 #1
3 1744
Have a look at the TopIndex property of the ListBox. I don't think that the
ComboBox has an easy property like this.

--
Tim Wilson
..Net Compact Framework MVP

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
How do I get the index of the first displayed item in list box / combo box? Thank you

Nov 17 '05 #2
Thanks, Tim.
That's the problem: I need it mostly for ComboBox! Is there an uneasy way?

"Tim Wilson" wrote:
Have a look at the TopIndex property of the ListBox. I don't think that the
ComboBox has an easy property like this.

--
Tim Wilson
..Net Compact Framework MVP

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
How do I get the index of the first displayed item in list box / combo

box?
Thank you


Nov 17 '05 #3
You can get it, or set it, through pinvoke. The code below shows how to get
the top index for a ComboBox.

using System.Runtime.InteropServices;

private const int CB_ERR = -1;
private const int CB_GETTOPINDEX = 0x015b;
private const int CB_SETTOPINDEX = 0x015c;

[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int
lParam);

....

int topIndex = SendMessage(this.comboBox1.Handle, CB_GETTOPINDEX, 0, 0);
if (topIndex != CB_ERR)
{
// Do something with "topIndex".
}
else
{
// Error
}

--
Tim Wilson
..Net Compact Framework MVP

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Thanks, Tim.
That's the problem: I need it mostly for ComboBox! Is there an uneasy way?

"Tim Wilson" wrote:
Have a look at the TopIndex property of the ListBox. I don't think that the ComboBox has an easy property like this.

--
Tim Wilson
..Net Compact Framework MVP

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
How do I get the index of the first displayed item in list box / combo

box?
Thank you


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peter Moscatt | last post by:
I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the...
3
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
1
by: jez123456 | last post by:
Hi, I have a windows form with a listbox control. My code all works correctly when deleting an item from the listbox except the last item. I get the following message when trying to delete the...
6
by: orahm | last post by:
I added an object to a listbox. This object is a complex number and not a string so it shows "Consolapplication.Complex" as a list item. If I convert the complex number to a string then it shows a...
6
by: David De Cotis | last post by:
Hello all, I am trying to go through a ListBox and verify if am item was selected. If an item was selected, I would like to get a handle of the item and simply do a response.write on the selected...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
3
by: perrycheung221 | last post by:
Hi guys, I got 2 listboxes in a window form, one on left and one on right. The 1st listbox have some items while the 2nd listbox is empty. Also there are 2 buttons between the 2 listboxes which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.