Free Support Forum - aspose.com

Number of items displayed in a list box

Hi

I am merging 2 rows and 4 columns in order to make up a list box.

Q1- what method can i use to put up a scroll bar in the list if the number of items in the list box are more than the height.

Q2- if I select a multiselect List Box, how do i get the values of all the items selected? Linked cell returns value of only 1 item selected.

Regards

Shalini

Hi Shalini,

Thanks for considering Aspose.

1). Well you don't need any method. If the list box has more items than its height, scrollbars automaticlally attached to it.

2). You may use ListBox.IsSelected(itemindex) method to check if an item is selected or not. Kindly check the following sample example for your reference. I used a template file attached:

//We have a list box which has three items selected i.e., first, third and fifth.

Workbook workbook = new Workbook();
workbook.Open("d:\\test\\tstlistbox1.xls");
Worksheet sheet = workbook.Worksheets[0];
Aspose.Cells.ListBox lst = (Aspose.Cells.ListBox)sheet.Shapes[0];

MessageBox.Show(lst.LinkedCell);
MessageBox.Show(lst.InputRange);
MessageBox.Show(lst.SelectedIndex.ToString());
MessageBox.Show(lst.ItemCount.ToString());
bool check0 = lst.IsSelected(0);
bool check1 = lst.IsSelected(1);
//true
MessageBox.Show(check0.ToString());
//false
MessageBox.Show(check1.ToString());

lst.SelectionType = SelectionType.Multi;
//Select the second item.
lst.SelectedItem(1, true);
//Select the 6th item (last item)
lst.SelectedItem(5,true);
check1 = lst.IsSelected(1);
bool check5 = lst.IsSelected(5);
MessageBox.Show(check1.ToString());//now it should be true.
MessageBox.Show(check5.ToString());//should be true now.

Thank you.

Hi Shalini,

Q1, Please check the post of Amjad.

Q2, Please try this fix. We add ListBox.SelectedCells property to get all selected cells. If the input range is not set or no item is selected, it will return null.

See following codes :

Aspose.Cells.Cell[] selectedCells = ((ListBox)(workbook.Worksheets[0].Shapes[0])).SelectedCells;
for (int i = 0; i < selectedCells.Length; i++)
{
Console.WriteLine(selectedCells[i].Value);
}

The property .selected items does not shows up. Do i need to import any dll for that ?

The scroll bar comes but still it compresses all the items in the list and do not show the text nicely. Please find attached the excel sheet.

Regards

Shalini

Shalini:

The property .selected items does not shows up. Do i need to import any dll for that ?

The scroll bar comes but still it compresses all the items in the list and do not show the text nicely. Please find attached the excel sheet.

Regards

Shalini

Hi Shalini:

The property .selected items does not shows up. Do i need to import any dll for that ?

Well, the property is .SelectedCells. Please make sure that you are using the newer .dll file. The property is added into the lastest component. I think you may try the following:

Please remove the reference of the previous Aspose.Cells.dll file and add reference to the newer Aspose.Cells.dll file (Which Warren has posted in this thread) into your Solution Explorer window.

The scroll bar comes but still it compresses all the items in the list and do not show the text nicely. Please find attached the excel sheet

I think you may increase the height of the list box and your the contents of the list box will be shown precisely.

Thank you.

Hi

I do not wish to increase the size of the listbox , though i want the text to be visible . Right now all the list items are overwriting each other. and the scroll bar appears in the side but does not give the scrolling facility, rather compressing the list inside to fit in the given space.

Please tell how to enable the scroll bar facility.

Please write the solution code in VB.NET and not C#

Hi,

You should increase the height of the list box and the contents of the list box will be shown precisely. We will also check to enhance the control soon.

Thank you.

hi

where is the attached dll ?

Hi,

Please download the lastest version of Aspose.Cells for .Net @: http://www.aspose.com/Community/Files/51/aspose.cells/entry111612.aspx

Thank you.

Hi

To download this dll, i have uninstalled the previous Aspose cells dll and then reinstalled in from the above mentioned path.

Now this dll requires version 1.1 of .NET installed when i have version 2.0 installed on my system. Please advice how to use it ?

Regards

Shalini

Hi,

We did some amendment work to support the successful installation on Windows Vista which require to use .NET framework 1.1 setup project. We will soon provide the supported .MSI so that you may not have to be installed the .NET 1.1 version. I think till then you can utilize Aspose.Cells.dll library, just add reference to the .dll in your vs.net project and use it (you may get the latest fix (4.4.1.3) from the recent forum posts) .

Please try the attached Aspose.Cells.dll.

Thank you.