Victor Charles
asked on
Help with displaying data selected in Listbox in Grid's cell.
Hi,
I am using a Listbox as a dropdown box in my Grid, how do I display rows selected in the Grid's cell separated by a comma?
For example if I select BEL, CAN and USA, I need to copy the data selected to the cell of the row selected in the following format: BEL,CAN,USA. and if I deselect USA, I need to only copy BEL,CAN to the cell of the selected row. Below is the current code I'm using to display the listbox as a dropdown box, but I can't display rows selected in the cell.
Private Sub C1TrueDBGrid45_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles C1TrueDBGrid45.Click
With ListBox1
.Left = Me.C1TrueDBGrid45.Left + Me.C1TrueDBGrid45.RecordSe lectorWidt h + Me.C1TrueDBGrid45.Splits(0 ).DisplayC olumns(0). Width + Me.C1TrueDBGrid45.Splits(0 ).DisplayC olumns(1). Width
.Top = Me.C1TrueDBGrid45.Top + Me.C1TrueDBGrid45.RowTop(M e.C1TrueDB Grid45.Row )
.Visible = True
.Select()
End With
End Sub
I am using a Listbox as a dropdown box in my Grid, how do I display rows selected in the Grid's cell separated by a comma?
For example if I select BEL, CAN and USA, I need to copy the data selected to the cell of the row selected in the following format: BEL,CAN,USA. and if I deselect USA, I need to only copy BEL,CAN to the cell of the selected row. Below is the current code I'm using to display the listbox as a dropdown box, but I can't display rows selected in the cell.
Private Sub C1TrueDBGrid45_Click(ByVal
With ListBox1
.Left = Me.C1TrueDBGrid45.Left + Me.C1TrueDBGrid45.RecordSe
.Top = Me.C1TrueDBGrid45.Top + Me.C1TrueDBGrid45.RowTop(M
.Visible = True
.Select()
End With
End Sub
ASKER
Hi,
How do I modify the code below to remove the first "," and when I click on another column, the list box still appears, how do I make it invisible? Me.ListBox1.Visible = False is not working.
Private Sub C1TrueDBGrid45_Scroll(ByVa l sender As Object, ByVal e As C1.Win.C1TrueDBGrid.Cancel EventArgs) Handles C1TrueDBGrid45.Scroll
Me.ListBox1.Visible = False
End Sub
Dim tempstring As String
Private Sub ListBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Leave
tempstring = ""
For Each item As Object In Me.ListBox1.SelectedItems
tempstring += "," + item
Next
Me.C1TrueDBGrid45.Columns( 1).Text = tempstring
Me.ListBox1.Visible = False
End Sub
How do I modify the code below to remove the first "," and when I click on another column, the list box still appears, how do I make it invisible? Me.ListBox1.Visible = False is not working.
Private Sub C1TrueDBGrid45_Scroll(ByVa
Me.ListBox1.Visible = False
End Sub
Dim tempstring As String
Private Sub ListBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Leave
tempstring = ""
For Each item As Object In Me.ListBox1.SelectedItems
tempstring += "," + item
Next
Me.C1TrueDBGrid45.Columns(
Me.ListBox1.Visible = False
End Sub
To Remove the first Comma
tempstring = ""
For Each item As Object In Me.ListBox1.SelectedItems
tempstring += "," + item
Next
if TempString.Text<>"" then
TempString=right(TempStrin g,len(temp String)-1)
End IF
Me.C1TrueDBGrid45.Columns( 1).Text = tempstring
Me.ListBox1.Visible = False
tempstring = ""
For Each item As Object In Me.ListBox1.SelectedItems
tempstring += "," + item
Next
if TempString.Text<>"" then
TempString=right(TempStrin
End IF
Me.C1TrueDBGrid45.Columns(
Me.ListBox1.Visible = False
To disappear the ListBox Check the possible events on The TrueDbGrid
Try On the RowUpdated also remember that the ListBox Will be contained inside a Cell in the Gridview. You need to DirectCast the control to make it Invisible according to the row index that you're in.
I think that you can Show/Hide the ListBox on the RowEditing/RowUpdated of each row and will be easy
Try On the RowUpdated also remember that the ListBox Will be contained inside a Cell in the Gridview. You need to DirectCast the control to make it Invisible according to the row index that you're in.
I think that you can Show/Hide the ListBox on the RowEditing/RowUpdated of each row and will be easy
ASKER
Hi,
I tried your code but received the following two error in the code below
If tempstring.Text <> "" Then **** Text is not a member of string.
tempstring = Right(tempstring, Len(tempstring) - 1) ****Readonly property Right has no parameters and can not be indexed.
End If
I tried your code but received the following two error in the code below
If tempstring.Text <> "" Then **** Text is not a member of string.
tempstring = Right(tempstring, Len(tempstring) - 1) ****Readonly property Right has no parameters and can not be indexed.
End If
Sorry was my bad.. the code must be
if TempString<>"" then
TempString=right(TempStrin g,len(temp String)-1)
End IF
if TempString<>"" then
TempString=right(TempStrin
End IF
ASKER
Hi,
I'm still getting the same error for "right"
****Read only property Right as integer has no parameters and can not be indexed.
I'm still getting the same error for "right"
****Read only property Right as integer has no parameters and can not be indexed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It works.
Thanks,
Victor
Thanks,
Victor
Open in new window
And on the click event Clear and go through the listItems of the Listbox and if is selected add it to the ListOfSelected, something like ListOfSelected+=ListItem+'