We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

gridboundcolumns, combobox and string types

Hi, I have a GridDataBoundGrid, for which I am building the GridBoundColumns collection by hand, column by column. I am trying to implement a ComboBox celltype on my grid. I have a simple demo that seems to work for enum types, but for a column with a string type, there are problems. In grid.PrepareViewStyleInfo, I am setting the following properties: StringCollection sc = new StringCollection(); sc.AddRange(...); style.CellType = "ComboBox"; style.DropDownStyle = GridDropDownStyle.Exclusive; style.ChoiceList = sc; What I am seeing is that the cell displays the drop-down arrow, but clicking on the arrow fails to drop down the list, and in every other way the cell behaves as a textbox. Any suggestions to make this work would be greatly appreciated.

5 Replies

AD Administrator Syncfusion Team March 16, 2004 10:43 PM UTC

PrepareViewStyleInfo is generally used for visual properties that are needed to draw the cell, like BackColor or Font. Properties that pertain to cell functionality like ReadOnly or Enabled or setting a Choicelist for a combobox, need to be done earlier in Model.QueryCellInfo. One comment is that you should only use either of these events if you need to dynamically set the properties on a whole column, or if you only want to set them for some cells in a column. If the properties apply to the whole column in a non-dynamic manner, then you should set the GridBoundColumn.StyleInfo for the column. This avoids these events (which are hit quite often) and probably gives better performance.


AD Administrator Syncfusion Team March 17, 2004 02:39 AM UTC

Thanks for your suggestions. Unfortunately, in most cases, the properties Im setting are capably of varying on a cell-by-cell basis.


AD Administrator Syncfusion Team March 17, 2004 04:22 AM UTC

Your previous suggestion on the roles of PrepareViewStyleInfo and QueryCellInfo worked. Thanks for that. Im now seeing the drop-downs appearing and functioning correctly. One problem remains... when I drop down the list and select a value, that value is shown in the cell, but isnt written to the datasource until you move the focus out of the cell, or press return or somesuch. I want selecting an item from the drop-down to immidiately display in the cell and write to the underlying datasource. I have DirectSaveCellInfo=true, but I dont think this is enough. The behaviour Im seeing would seem to be bound to the drop-down itself.


AD Administrator Syncfusion Team March 17, 2004 10:37 AM UTC

You can try this. In CurrentCellCloseDropDown, if the reason is not a cancel, then try calling grid.CurrentCell.ConfirmChanges. This should save the value at this point.


AD Administrator Syncfusion Team March 17, 2004 10:41 AM UTC

If ConfirmChanges is not enough to flush the value to the DataSource, then also try calling grid.Binder.EndEdit. The reason ConfirmChanges may not be enough is that the grid will cache changes to a row, and only call binder.EndEdit when you leave the row, and it is this point that the changes finally get saved.

Loader.
Live Chat Icon For mobile
Up arrow icon