You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Pages: 1
Topic closed
Dim x As New DropdownListCell
x.Items.Add("aaaa1")
x.Items.Add("aaaa2")
x.Items.Add("aaaa3")
Grid.CurrentWorksheet.ColumnHeaders("B").DefaultCellBody = GetType(unvell.ReoGrid.CellTypes.DropdownListCell())
Grid.CurrentWorksheet.SetCellData("B", x)
DropDownListCell created successfully, but DropDownListCell Items not added to all the rows.
Offline
How many rows on your worksheet?
Last edited by Jingwood (2015-02-11 09:29:31)
Offline
5000 rows sir,
Offline
OK since the default built-in DropdownListCell will create one ListBox instance for one cell, it will be many ListBox control instances in memory if you have so many rows. Below is a solution that the ColumnDropdownListCell class only create one ListBox control instance in memory and it will be commonly used for all cells on entire column.
Class ColumnDropdownListCell: (VB.NET)
Class ColumnDropdownListCell
Inherits DropdownCell
' Create only one listbox instance that is commonly used for entire column
Shared listbox As New ListBox With {
.BorderStyle = Windows.Forms.BorderStyle.None
}
Shared Sub New()
' Initialize listbox items
listbox.Items.AddRange({"A", "B", "C"})
End Sub
Sub New()
' When cell body instance created, set listbox as dropdown control
MyBase.DropdownControl = listbox
End Sub
Public Overrides Sub PushDown()
' Add event listener when got focus
AddHandler listbox.Click, AddressOf ListBox_Click
MyBase.PushDown()
End Sub
Sub ListBox_Click(s As Object, e As EventArgs)
' Choose listbox item, set to cell as data
MyBase.Cell.Data = listbox.SelectedItem
' Remove event listener when lost focus
RemoveHandler listbox.Click, AddressOf ListBox_Click
' Close dropdown panel
MyBase.PullUp()
End Sub
End Class
Use it:
' Set default body type
Me.worksheet.ColumnHeaders("B").DefaultCellBody = GetType(ColumnDropdownListCell)
' Initialize dummy data
Me.worksheet("B1:B9") = {"A", "B", "C", "A", "B", "C", "A", "B", "C"}
Offline
Thank you sir,
It is working.....
Offline
Pages: 1
Topic closed