6 Answers, 1 is accepted
0
Emanuel Varga
Top achievements
Rank 1
answered on 26 Nov 2010, 03:33 PM
Hello,
Please take a look at the solution i have provided here, you can easily implement this operations using a context menu, or you could handle the KeyDown event in a custom grid behavior to send the text to the clipboard.
Please let me know if you need an example for the second option.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Please take a look at the solution i have provided here, you can easily implement this operations using a context menu, or you could handle the KeyDown event in a custom grid behavior to send the text to the clipboard.
Please let me know if you need an example for the second option.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Diederik
Top achievements
Rank 1
answered on 26 Nov 2010, 03:47 PM
Hi Emanuel,
Could you provide me the example of the second option?
Thanks for your fast response.
Diederik.
Could you provide me the example of the second option?
Thanks for your fast response.
Diederik.
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 26 Nov 2010, 04:12 PM
Hello again,
Please take a look at the following example:
This will just copy the text from the current cell, about the pasting, where do you want to paste that value because i'm guessing not in the readonly cells.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Please take a look at the following example:
using
System.ComponentModel;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
public
partial
class
Form1 : Form
{
private
RadGridView radGridView1;
public
Form1()
{
InitializeComponent();
this
.Controls.Add(radGridView1 =
new
RadGridView());
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.Dock = DockStyle.Fill;
radGridView1.DataSource =
new
TestsCollection();
radGridView1.ReadOnly =
true
;
radGridView1.GridBehavior =
new
CustomGridBehavior();
}
private
class
CustomGridBehavior : BaseGridBehavior
{
public
override
bool
ProcessKeyDown(KeyEventArgs keys)
{
if
(keys.KeyData == (Keys.Control | Keys.C))
{
Clipboard.SetText(
this
.GridControl.CurrentCell.Value.ToString());
}
return
base
.ProcessKeyDown(keys);
}
}
}
public
class
Test
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
}
public
class
TestsCollection : BindingList<Test>
{
public
TestsCollection()
{
for
(
int
i = 0; i < 10; i++)
{
this
.Add(
new
Test
{
Id = i,
Name =
"Name"
+ i
});
}
}
}
This will just copy the text from the current cell, about the pasting, where do you want to paste that value because i'm guessing not in the readonly cells.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Michal Zámec
Top achievements
Rank 2
answered on 19 May 2011, 09:33 AM
Hi,
those examples you've provided are only able to select (copy) whole value of the cell. Is there a way to implement behavior, which will allow user to select just part of the text in read-only grid using mouse? I need to implement access-like behavior, where you easily could select part of the text in grid cell and use that selected text for other actions (for example fliter by context menu etc).
Thans
those examples you've provided are only able to select (copy) whole value of the cell. Is there a way to implement behavior, which will allow user to select just part of the text in read-only grid using mouse? I need to implement access-like behavior, where you easily could select part of the text in grid cell and use that selected text for other actions (for example fliter by context menu etc).
Thans
0
Emanuel Varga
Top achievements
Rank 1
answered on 20 May 2011, 08:57 AM
Hello Michal,
In order to achieve your desired behavior you first will need to be able to show a textbox on the cell, in order to select part of that text, i believe if you are ok with doing things this way, it could be possible, BUT, you cannot rely on the grid being readonly anymore you will have to threat all different editors to show up, but to negate any edit operation (based on each editor type).
So in conclusion, it is doable, but it will take more work for some editors, for textbox it's easy, for datetimepicker & combo not so much.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
In order to achieve your desired behavior you first will need to be able to show a textbox on the cell, in order to select part of that text, i believe if you are ok with doing things this way, it could be possible, BUT, you cannot rely on the grid being readonly anymore you will have to threat all different editors to show up, but to negate any edit operation (based on each editor type).
So in conclusion, it is doable, but it will take more work for some editors, for textbox it's easy, for datetimepicker & combo not so much.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Hello Michal Zámec,
Currently we do not provide such functionality in RadGridView. You have to implement it in the way Emanuel suggested. However, this is a nice feature and I added it in our issue tracking system as a feature request. I updated also your Telerik points. We will consider implementing it in a future version of our controls.
If you have any other questions, do not hesitate to ask.
All the best,
Jack
the Telerik team
Currently we do not provide such functionality in RadGridView. You have to implement it in the way Emanuel suggested. However, this is a nice feature and I added it in our issue tracking system as a feature request. I updated also your Telerik points. We will consider implementing it in a future version of our controls.
If you have any other questions, do not hesitate to ask.
All the best,
Jack
the Telerik team