Hey all,
I have a UltraGrid displaying a certain # of informations, and everything works well until....
i am adding a "custom" colum (if i may say) at the end of the grid. the custom column is only supposed to display the # of rows, for instance on row 1, i will have X # of details, and the last cell will be named "Items" with for value 1, row 2 will have for value 2 etc....
I can add the column with ease, but where i get stuck is when i try to add values into that column.
this is wut i do:
in the Grid_InitializeLayout Event :
e.Layout.Bands(0).Columns.Add("Items", "Items")
and in some method i do:
Dim CustValues As ValueList = New ValueListDim i As Integer = 1
While i < UltraGrid11BatchJobsHistory.Rows.Count CustValues.ValueListItems.Add(i) i += 1 End While
UltraGrid11BatchJobsHistory.DisplayLayout.Bands(0).Columns("Items").ValueList = CustValues
When i check the grid, i DO see the new column called ITems, but it has no value
can someone please help ?
Thank in advance
John
Hi John,
After you set the Value on the cell, the row is considered dirty, since this change has not been written to the underlying data source. What you need to do is call Update on each row inside your loop.
Dim i As Integer = 1
While i < MyGrid.Rows.Count + 1 MyGrid.Rows(i - 1).Cells("Items").Value = i
MyGrid.Rows(i - 1).Update() i += 1 End While
Mike,
Thank you for your response. Right after posting i realized that i wasn't assigning any value to the cells (like you said). So i added :
While i < MyGrid.Rows.Count + 1 MyGrid.Rows(i - 1).Cells("Items").Value = i i += 1 End While
and it works well.
however, on the grid i added the properties :
MyGrid.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;
MyGrid.DisplayLayout.Override.RowSelectorStyle = HeaderStyle.WindowsXPCommand;
and on my grid, i do see the row selectors, but it doesn't display like i want it to (the look and feel).
for each rows, to the very left, the row selector shows with a "pen and couple dots" and what i would like is a solid square (for the row selector). Does it have anything to do with the fact that the grid is editable? if so, how could i make sure the grid ISN'T editable, the informations displayed in the grid are informational and users should not be able to edit anything.
or if i may say, how can i make sure the grid is READONLY ?
Thank you,
I'm not sure I understand your question. You are assigning a ValueList to the column, which means that the cells in this column will have a dropdown list of values that the user can choose. Are you saying that the dropdown is not showing up?
You seem to be saying that the cells in this column have no value. But that is correct. There is nothing in your code here that assigns a Value to the cell, you are only assigning a ValueList, which is not at all the same thing.
If you want to assign a Value to the cell, then I recommend using the InitializeRow event of the grid. The code would look something like this:
e.Row.Cells("Items").Value = someValue