I have DevExpress ASPxGridView which bind data from the code and columns will add dynamically. I want to set the columns editable. (User should able to type on grid cells)
Is there any way to do this? (Something like my code)
For i As Integer = 0 To dgstkReceivd.Columns.Count - 1
dgstkReceivd.Columns(i).EDITABLE = True
Next
Unlike the WinForms Grid, a user has to manually switch the WebForms Grid to Edit mode. DevExpress ASPxGridView provides several Edit modes:
Edit Form
Popup Edit Form
Inline editing
Batch editing
See the Data Editing help topic on DevExpress.
For your requirements, I guess, inline and batch edit modes will suite them.
Batch edit mode does not need a user to click the Edit button.
Use the ASPxGridView.SettingsEditing.Mode property to enable the required Edit mode for the Grid. For Edit modes except Batch, you also need to show the Edit button. Use the properties of the Command Column to do this.
Here is a demo: Grid Edit Modes
Updated
To prevent a particular column from being edited, you can use the GridViewDataColumn.ReadOnly property. You can also set the e.cancel parameter of the ASPxClientGridView.BatchEditStartEditing event handler to true to disable editing based on your condition on the client.
You can manage whether user can edit the specific column or cannot via the OptionsColumn.AllowEdit option.
This option is in effect if the View's ColumnView.Editable property is set to true.
The default state of these options makes columns editable if it possible. For example, if the column in DevExpress XtraGrid is mapped to read-write property of a specific data-object then this column is editable by default.
Related help-articles:
Assigning Editors to Individual Cells
WinForms Grid: Prevent Editing in Specific Cells.
Related
I am trying to find any information about using a radio button in a rad grid in batch edit mode. I have created a template column, then added the radio button control, but it doesn't work in batch edit mode (nothing saves back to the DB). Is it even possible? I can't find anything on the Telerik site so I am suspecting its not supported. Thanks.
The Radio list is not supported in the batch editing mode. Such integration simply has not been implemented. The closest available option at this time is using a dropdown list: http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx. Generally speaking, the standard way of editing boolean fields is through a checkbox column and not a radio button list - check the Discontinued checkboxes column.
What the grid does is that it loops through the controls with JS code when cells are opened and closed and determines control types and the proper API to use (e.g., $get().control.get_value() for dropdownlists, or $get().value for standard inputs). You can try implementing similar logic in the batch editing events.
You can try to use a RadRadioButtonList with the two items declared in its markup and its client-side API (see the get_selectedIndex() and set_selectedIndex() method: https://docs.telerik.com/devtools/aspnet-ajax/controls/radiobuttonlist/client-side-programming/radiobuttonlist-object) together with the following approach of working with templates: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/working-with-templates.
The idea is to have the radio button list in the edit template of the column and to select the correct item in it according to the newly opened cell value on the client, then fetch the selected item from the button list and put it in the grid data source.
You can find one example that you can try using as base in the following thread: https://www.telerik.com/forums/radiobuttonlist-in-gridtemplatecolumn.
Showing a radio button list in the item template is also something that is not supported, as the editing would basically happen in the "display" mode of the cell, and not in the edit mode of the cell. You could try using the server ItemDataBound event and FindControl() (see here: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-template-column) may let you set initial values based on the data source for the radio button lists without data binding them. Then, perhaps a hidden field or hidden checkbox can be used for the actual data binding (see the template article above). You could also try using the batch editing manager changeCellValue() method on the client-side events of the radio button list, in a fashion similar to this article: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/how-to/editing-checkboxes.
Another approach you can consider is to use the client-side events of the radio button list and immediately upon change to call a service that will update the database. This may simplify the template handling logic (you could do this in a read-only column) but it goes against the purpose of batch editing to invoke one request with a lot of data, and you would also need to secure the service.
Another online resource to check is
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/how-to/editing-checkboxes
Please refer to the azure link for the built code and github link for the source code. To explain the scenario, I have a q-datatable from Quasar Framework. Since I have nested data, I am populating primary data in a collapsible for loop and secondary data in the content of collapsible as a datatable. The page also features an Edit/View Mode toggle just below the filters on the right. I have formatted the columns of the datatable to show q-input when in Edit Mode and just text in View Mode. Please do the following operation to reproduce the error. Steps 5 and onward are the steps producing unexpected behavior.
Expand one of the rows at the link(open in new window manually).
Toggle the Edit/View toggle which can be found just below the filters.
Trying editing any row. Observed Result: The values do persist in the text boxes on leaving focus, and also in the labels when page mode is changed back to View mode.
Add a new row by clicking on Add button found just below the row header.
Try typing in any of the text boxes in the newly added row and move to the ext text box. Observed Result: The values do not persist in the text box neither do they show in the labels when changed to View Mode.
Change mode back to View Mode and then back to Edit Mode. Observed Result: Values do show in the text boxes in edit mode but not in the View Mode.
Add a new row. Observed Result: Now the previously added row values show in both Edit and View Modes.
The problem was in the AddRow method. It is stated in the documentation that vue can only track changes to objects with defined properties. In the AddRow method I was adding an empty data object to the model. Adding properties with null values fixed the issue.
Is it possible to change the "default" forecolor of a label?
I know I can change each control one-by-one in either design time or run time but I wonder if there is a better way.
I can do this at run time
lblCompanyName.ForeColor = color.darkblue
I could also have a loop to look at all of my controls on the form and change them in one small bit of code, but there must still be a better way.
I see at design time that the "default" label forecolor is "ControlText" so can I change ControlText perhaps to equal color.darkblue and then all of my labels will be dark blue without needing to code it one control at a time (or within a loop).
Thankyou
David.
You can't change it for a standard Label control but you can always create your own class that inherits Label and then sets the ForeColor property in the constructor. You would then use that control instead of a Label.
EDIT:
If you want to change the text colour for all your Label controls at run time then you should use a bound application setting. On the Settings page of the project properties, add a setting of type Color with User scope and name it LabelForeColor or something else if you prefer. Now, select a Label in the designer, open the Properties window and use the (ApplicationSettings) -> (PropertyBindings) node to bind the ForeColor property to the setting you created.
You can then access that setting in code via My.Settings.LabelForeColor and any Label bound to it will be updated automatically. You can bind as many different Label controls on as many different forms as you like. You can only bind one at a time though, so I would recommend copying and pasting an existing bound Label rather than adding a new one each time. If you have existing Label controls and you're confident enough, you can copy, paste and edit the binding code in the designer code file(s).
There's really no point your using a custom control in this case because the setting will control each control anyway. No matter what value you set in the constructor, it will still be set by the bound setting afterwards. Note that any change you make to a setting will be automatically saved at shutdown and reloaded at startup.
I've created one user control which have textBox & DatabGridView etc. When any user start typing in textbox then the filter is applied in DatabGridView. Now I want to add following features in this control how can I add these?
I want to use same control for supplier, customer, vendors on a single form, so I've placed it 3 times from toolbar. But for each control I want to fill different data from database. So what will be the best way to bind the control?
As we knew each table (customer,supplier & vendor) can have different columns, so I also need properties to set them. I've added property to my control but how can I ensure user has assign value in it? I.e. if user run the form and X property is not assigned to control then it should show message.
Note: I've tried it on control load event but didn't get any success because control's load event is occurred prior to form load and I'm assigning property on form load.
Please help....
I'm creating an addin button in Arcmap via VB.net that when clicked, runs the identify tool. But I want only selected fields to appear in the identify dialog. I thought of hiding the unnecessary fields and then showing them again after the button is used.
Does anyone know how to programmatically turn off/on field?
you have to iterate the fields in layer and then set visible property into false .
see this link in
gis.stackExchange