i would like the Cells in my ultraGrid (1 Column) to not have the text field editable when bound to a UltraDropDown
I believe I am having a similar issue to the person in this thread:
http://www.infragistics.com/community/forums/p/3440/18306.aspx
My problem is that even though I set the UltraDropDown's Column style and the UltraGrid's Column style to UltraWinGrid.ColumnStyle.DropDownList they are still editable before and after selecting somthing from the list. I think this may be caused because not every row has a UltraDropDown List bound. This is because some rows need to be editiable by the user.
I have a UltraComboEditor on anjoter part of the page working the way I would like the ultraDropDown's to work in the grid by using UltraComboEditor1.DropDownStyle = DropDownStyle.DropDownList
I can post some code if it helps, but just figured I'd ask if this is a known bug.
Also posted on Stack Overflow with images http://stackoverflow.com/questions/18403477/infragistics-ultradropdown-in-ultragrid-disable-editing-text-ultrawingrid-colu
Sorry I wasn't clear but yes I did get it working. Thank you very much for the help.
Hi,
You lost me. Do you have it working now, or not? Your last post is not clear.
This code looks correct to me. If it's not working, then something must be resetting the Style on the cell after you are setting it here.
The exception you got could be because InitializeRow is firing before "List" or "Values" column has been added to the grid. This can happen if these are unbound columns that you are adding after the grid it bound. This is very easy to fix, though. Just check band.Columns.Exists and if the column does no exist, bail out of InitializeRow. The event will fire again when the column is added.
Thank yu for your help, i ended up using
I also tried this with zero errors but it did not work:
Private Sub UltraGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles UltraGrid1.InitializeRow
If e.Row.Band Is Me.UltraGrid1.DisplayLayout.Bands("Bottom") Then
If e.Row.Cells("List").Value Is "" Then
e.Row.Cells("Values").Style = UltraWinGrid.ColumnStyle.DropDownList
End If
End Sub
I was actually setting the drop down when creating each row. The data I am being passed is parsed into arrays from XML files. This results in me setting each cell one at a time. Code looks something like this
reportName = UltraGrid1.DisplayLayout.Bands("Top").AddNew() 'add top level row to grid reportName.Cells("Report").Value = array3(1, i) 'report name to new row For k = 1 To array3(3, i) 'loop for amount set in parent array parameterName = UltraGrid1.DisplayLayout.Bands("Bottom").AddNew() 'add bottom level row to grid parameterName.Cells("List").Value = array1(7, counter) If Not parameterName.Cells("List").Value = "" Then parameterName.Cells("Values").ValueList = UltraDropDown1 parameterName.Cells("Values").Value = array1(8, counter) parameterName.Cells("Values").Style = UltraWinGrid.ColumnStyle.DropDownList Else parameterName.Cells("Values").Value = parameterName.Cells("HiddenVal").Value 'set for textbox parameterName.Cells("Values").Style = UltraWinGrid.ColumnStyle.Edit End If Next
reportName = UltraGrid1.DisplayLayout.Bands("Top").AddNew() 'add top level row to grid
reportName.Cells("Report").Value = array3(1, i) 'report name to new row
For k = 1 To array3(3, i) 'loop for amount set in parent array
parameterName = UltraGrid1.DisplayLayout.Bands("Bottom").AddNew() 'add bottom level row to grid
parameterName.Cells("List").Value = array1(7, counter)
If Not parameterName.Cells("List").Value = "" Then
parameterName.Cells("Values").ValueList = UltraDropDown1
parameterName.Cells("Values").Value = array1(8, counter)
parameterName.Cells("Values").Style = UltraWinGrid.ColumnStyle.DropDownList
Else
parameterName.Cells("Values").Value = parameterName.Cells("HiddenVal").Value 'set for textbox
parameterName.Cells("Values").Style = UltraWinGrid.ColumnStyle.Edit
Next
When I tried to write a InitializeRow event i was caught with "ArgumentException: Key not found: 'List' Parameter name: key"
Private Sub UltraGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles ultraGrid1.InitializeRow
If e.Row.Cells("List").Value = "" Then
UltraGrid1.DisplayLayout.Bands("Bottom").Columns("Values").Style = UltraWinGrid.ColumnStyle.DropDownList
Okay. That's very easy.
grid.DisplayLayout.Bands[1].Columns["Values"].Style = ColumnStyle.DropDownList;
If you have to do this for some cells and not other, then use the InitializeRow event and set the Style property on the Cell to DropDownList. Presumably you are already using InitializeRow to apply the dropdown to the cell, so you would set the Style on the cell at the same time.