DevExpress GridControl cells' inner text selectable but not editable - devexpress

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

Related

Get data from any cell in Grid Control of DevExpress

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

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?

How to implement excel-like formula editor in XtraGrid?

I'm working on complicated system, which allows some values in grid to be calculated by formulas.
Right now I have textbox control above grid.
It works in this way:
When you start editing inside in-place editor and first symbol is '=' - focus is moved to that textbox control above.
At this moment grid is made readonly, and when user clicks on grid cells - coordinates of the clicked cell are passed to formula editor, so it can add links to formula. When you press Enter or Esc in text editor - formula is being written to underlying dataset and grid is made editable back.
The goal:
I want this too look more like Excel grid. Don't like focus to jump somewhere outside.
Is it possible to keep editor open and at the same time allow user to click anywhere on grid? So, all formula editing will be performed inside inplace editor?
Right now, there's no event to disallow closing editor. If I use 'ValidateEditor' event - it doesn't even allow to use scrollbars.
Is there a way to keep editor open and leave navigation working?
Seems I have found way round that myself.
I handle ValidatingEditorEvent, and if edit value starts with '=' I set boolean flag in my control. Also, I remember text before and after cursor position, and cell coordinates (FocusedRowHandle, FocusedColumn).
When I receive Click event, I get clicked cell coordinates and if boolean flag is set - I focus previous cell, activate editor and add what I need to inpalce editor.
Seems to work fine.

Flex edit DataGrid cell on click only when previously selected

I need to modify the behaviour of an editable datagrid to this:
-Single-click on a row, doesn't make the cell show a text input field (only selects the row)
-Double-click on a row, doesn't make the cell show a text input field either
but
-Clicking a cell in an already selected row, shows a text input field ready to be edited.
I belive this is how for example iTunes works.
I found a solution.
I ended up using the ListEvent.CHANGE to tell if the selectedIndex index had changed,
and then the preventDefault on ITEM_EDIT_BEGINNING if it was.

Using the Tab key to navigate form inputs

I am having some problems with tabbing within my asp.net pages. This project was developed with Visual Studio 2008.
Case 1
I have two html tables. The first table has two rows; the second table has four rows. Within the cells are of each table are asp.net fields, text boxes and radio button lists. I set focus to the first field of table one. I then press the tab key multiple times. The focus moves through the field of table one and then through the fields in the first row of the table two. Then instead of goes to the second row of the table two it return to the table one.
But if I set focus to the last cell on the first row of table two, it tabs through the remaining cells of table two properly. Can you tell me how to get the tabbing to behave properly and go to the cells in there natural order? Note that I am setting the tab index property in the order that I want.
Case 2
On another page I have an html table with a single row followed by a gridview control. The gridview control is writeable and has the following columns: Check Box, Radio Button List, Text Box, Text Box, Text Box and a Check Box List. If I click on one of Check Box, Radio Button List or Check Box List., then press tab, the cursor pops out of the grid and sets focus on the first field of the table outside the grid. But if I set focus on one of the text boxes and tab; then the tab goes through the fields of the grid left to right one row at a time. This later behavior is what I want in both cases. I don’t know why my cursor pops out of the grid when I start with a field other than a text box.
Please help if you can.
Bob
funny, you explain in details your case but you didn't explain what it needs to be explained in order to someone can understand you :)
first of all, is table1 located in the first tab and table2 in second tab?
what do you used for tabs: asp.net tab control, jquery ui tabs...?
what do you mean by 'press the tab key multiple times'? same tab? do you have postback on tab click? what is the focus in your case, and so on and on...
cheers
Have you checked the order of the input elements in your HTML? Generally the tab order follows the order of controls.
If that all looks right, then make sure nothing is setting the TabIndex property - as this will also mess up the tab order.
I pretty much resolve this and I wanted to add the answer for anyone who viewed this thread. The problem was the autpostback on certain fields. Once I disabled autopostback, the problems went away.
Bob
You need to use Javascript and I referred for your a very good example of navigating through Gridview rows with Up/Down keys.
http://www.codeproject.com/Articles/25675/GridView-Rows-Navigation-Using-Arrow-Up-Down-Keys

Resources