Get data from any cell in Grid Control of DevExpress - grid

I want to get data from any cell in DevExpress Grid control to assign to a textbox.
So how to get any cell data can be passed through it's address?

To obtain a cell value use the GridView.GetRowCellValue method.

I may be jumping ahead, but it sounds like you may want to take the text from a given column in a highlighted row and apply it to a text box somewhere else on the form.
If this is the case, I highly recommend a binding source. Bind the actual data to the binding source, then make the binding source the DataSource for both your grid and your text box.
If you go to the text box's DataBinding->Advanced Property, you will see how to bind it to the appropriate property. When you click on various rows in the grid, you will change the .Current property of the binding source, which will automatically update the text in the text box.
Or, one better, use the Dev Express DataLayout, which does the heavy lifting (and much more) for you.

TextBox.Text=GridView_Name.GetRowCellValue(GridView_Name.FocusedRowHandle, GridView_Name.Columns[Number of column]).ToString();This is the answer

Related

DevExpress GridControl cells' inner text selectable but not editable

GridControl is working like~ Excel natively:
Clicking once on the cell selects it. Copy copies the cell value and the header.
Clicking twice on the cell selects the inner text. Copy copies only the inner text.
I am working on preventing the cell edition hooking the ShowingEditor event, setting the edition to e.Cancel.
However this prevents the behaviour 2. above. I'd like to still be able to select the inner text for copy, just that I'd like it to be not editable.
Would you know how to do this? Fyi, this behavior can be achieved at a column level by setting the ReadOnly to true:
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="field" ReadOnly="True"/>
EDIT
My grid is setup like this:
<dxg:GridControl>
<dxg:GridControl.Resources>
</dxg:GridControl.Resources>
<dxg:GridControl.View>
<dxg:GridControl.TableView>
</dxg:GridControl.TableView>
</dxg:GridControl.View>
<dxg:GridControl.Columns>
</dxg:GridControl.Columns>
</dxg:GridControl>
Thank you!
Have you tried
GridView.OptionsBehavior.CopyToClipboardWithColumnHeaders = False
Also you could try this approach suggested by DevExpress
Copy single cell content to clipboard from XtraGrid when user presses Ctrl+C

Powerbuilder Excel-Cell like edit functionality on Datawindow Grid

I've been given a very unusual request of emulating excel-like editing functionality for my grid.
Here's the scenario: The users would like to be able to immediately change the content by clicking on the cell and typing whatever they wish. Currently, they have to double click on the cell to block select the content, and then type in their desired text to overwrite the cell contents. They'd like the intermediate step of double clicking to block select the text to be taken out. The editable cells hold only numbers.
So I have two options:
1. Automatically block select the cell contents as soon as the user clicks on it
2. Make the cell selection/edit behave the same way as excel
Given Powerbuilder's inherent limitations, I'm fairly convinced this is impossible without some wacky hack, but I'd like to hear ideas.
PowerBuilder does handle this with ease but you can look like a hero to your end-user now.
:)
Auto Select Text in Datawindow Edit Fields
In your datawindow painter, choose the column, then check the "auto select text" property. This will cause your text to be selected as soon as the field gets focus. Now the problem is that PB doesn't provide this feature for edit mask controls but you can get around that yourself using the below example.
Auto Select Text in Edit Mast controls in Datawindow
Add code to your datawindow control that checks for an edit mask field and highlights the text. The example could be put into the itemfocuschanged event of the datawindow control, or in your datawindow control ancestor.
// only if row present
if row > 0 then
if describe( dwo.Name + '.Edit.Style' ) = 'editmask' then
// we found an edit mask so select the text in it
this.selecttext(1,len(string(getitemstring(row,dwo.Name))))
end if
end if
Did you try the Auto Selection edit property?

Advanced DataGrid Flex 3 - ItemRenderer and Tree display

I am using Advanced DataGrid of Flex 3 with hierarchical data. The itemRenderer is a TextInput which accepts numbers. When I enter data into the given field and click the corresponding expand tree icon for the row, I want the amount entered in tree node should get cascaded to its child rows. But I found the nature of advanced DataGrid erroneous.
When I enter data and click on tree icon, the data is not populated in child windows unless i wont take the focus out from the editing control.
I tried using itemEditEnd, itemFocusOut etc but of no use. I have to explicitly click on any of the other columns and then expand tree.
Am I making any mistake anywhere?
I found solution to my problem, its bit ugly but it works. I had to register two events for textinput as follows
addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, allocateAmount);
addEventListener(FocusEvent.KEY_FOCUS_CHANGE, allocateAmount);
and then by using IViewCursor I could able to update data.

Flex datagrid control with expanding rows

I'm looking for a DataGrid with expandable rows implementation in Flex. I don't want to use Advanced DataGrid control because it's too slow and too complex.
The desired behavior is like this: when you click a row, a panel opens between the rows with some details and the rest of the rows are moved down, and when you click again the panel is closed and the rows are back to normal. If you click the other row, the one that was expanded collapses and the row you clicked is expanded.
You'll probably need to use a custom ItemEditor that responds to clicks and expands itself.
The variableRowHeight property may need to be set to true as well.
The behavior you are describing sounds an awful lot like an Accordion component, though that doesn't quite sound like what you are looking for. Another approach would be to use a List component with a custom itemRenderer that is expanded when in the selected (clicked) state, and collapsed when not selected.
We extended Flex Datagrid component and used custom item renderer for this. We actually expand one cell and resize it to cover all other cells in the same row. While this may be not the easiest solution it works and the Datagrid is very fast.

ASP:ListBox | Multi Select | Keep selected values when selecting a new one

1) Have a listbox with 3 values out of 5 selected
2) When I click to select another value without holding CTRL button, it will unselect over values
How to make it keep other selected values if new value is selected?
This is going to sound like a snide answer, but I don't mean it that way. I just like to look for the simple solutions rather than the complicated onces.
The easiest way to get a control to have the behavior you want is to use a control that has the behavior that you want, rather than modifying the behavior of an existing control.
That said, if you want a list of items where a user can select a bunch of items off the list, and don't want to have to rely on them holding control, you're using the wrong tool for the job.
Use a CheckBoxList instead of a ListBox. If you want it to be scrollable, then set it in a div of a specific height, and set the style of the div to "overflow: scroll".
If you still want to use a ListBox you should use javascript and for each click event fired, you should check if the clicked element is selected/unselected and act accordingly. It's a little bit tricky but at least it is a solution for your problem.

Resources