Hello,
I'm testing at this moment the grid control.
The intention of the application is that the user loads an Excel File and that the content is loaded in a gridview. This works succesfull.
The next step is that the user gets a collection of columns using a webservice. These columns are listed in a frame, sort of a multiline textbox.
The user drags and drops a such a columnname to a column of the grid. At that point I must mark this column as assigned and change the caption of the column header to the new value.
Is there solution to make this possible?
Thanks
I'm testing at this moment the grid control.
The intention of the application is that the user loads an Excel File and that the content is loaded in a gridview. This works succesfull.
The next step is that the user gets a collection of columns using a webservice. These columns are listed in a frame, sort of a multiline textbox.
The user drags and drops a such a columnname to a column of the grid. At that point I must mark this column as assigned and change the caption of the column header to the new value.
Is there solution to make this possible?
Thanks
6 Answers, 1 is accepted
0
Geert
Top achievements
Rank 1
answered on 26 Feb 2009, 10:29 AM
Another way of creating this is to generate a dropdowncolumnheader.
In this dropdowncolumn you can select one field. once You have selected a field, it is not possible to select it in another column.
Maybe this is possible?
In this dropdowncolumn you can select one field. once You have selected a field, it is not possible to select it in another column.
Maybe this is possible?
0
Hello Geert,
Thank you for your questions. I have created a sample application that demonstrates how to achieve the scenario from your first forum post - please see the attached file. You need to handle the standard Drag and Drop events. You also need the GetElementAtPoint method.
Your second scenario is actually harder. Please write me back if you need it too.
Here is the code so that it can be more easily reviewed by the other community members:
Do not hesitate to write me back if you have further questions.
Best wishes,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for your questions. I have created a sample application that demonstrates how to achieve the scenario from your first forum post - please see the attached file. You need to handle the standard Drag and Drop events. You also need the GetElementAtPoint method.
Your second scenario is actually harder. Please write me back if you need it too.
Here is the code so that it can be more easily reviewed by the other community members:
public partial class Form1 : Form |
{ |
public Form1() |
{ |
InitializeComponent(); |
} |
private void radGridView1_DragDrop(object sender, DragEventArgs e) |
{ |
RadListBoxItem itemToDrop = (RadListBoxItem)e.Data.GetData(typeof(RadListBoxItem)); |
Point point = PointToClient(new Point(e.X, e.Y)); |
point.X -= this.radGridView1.Location.X; |
point.Y -= this.radGridView1.Location.Y; |
RadElement element = this.radGridView1.ElementTree.GetElementAtPoint(point); |
if (element is GridDataCellElement) |
{ |
((GridDataCellElement)element).ColumnInfo.HeaderText = "New Caption"; |
} |
} |
private void radListBox1_MouseDown(object sender, MouseEventArgs e) |
{ |
startDrag = e.Location; |
pointedItem = this.radListBox1.ElementTree.GetElementAtPoint(e.Location); |
if (pointedItem is RadListBoxItem) |
{ |
if (pointedItem != null) |
{ |
this.radListBox1.SelectedItem = (RadListBoxItem)pointedItem; |
} |
} |
} |
private void radListBox1_MouseMove(object sender, MouseEventArgs e) |
{ |
if (this.IsRealDrag(e.Location) && pointedItem != null) |
{ |
this.radListBox1.DoDragDrop((RadListBoxItem)pointedItem, DragDropEffects.Move); |
pointedItem = null; |
} |
} |
private bool IsRealDrag(Point location) |
{ |
if (Control.MouseButtons != MouseButtons.Left) |
{ |
return false; |
} |
if (startDrag == Point.Empty) |
{ |
startDrag = location; |
} |
else |
{ |
int xOffset = Math.Abs(startDrag.X - location.X); |
int yOffset = Math.Abs(startDrag.Y - location.Y); |
if (xOffset >= SystemInformation.DragSize.Width || |
yOffset >= SystemInformation.DragSize.Height) |
{ |
return true; |
} |
} |
return false; |
} |
Point startDrag = Point.Empty; |
RadElement pointedItem = null; |
private void radGridView1_DragEnter(object sender, DragEventArgs e) |
{ |
if (e.Data.GetDataPresent(typeof(RadListBoxItem))) |
{ |
e.Effect = DragDropEffects.Move; |
} |
} |
} |
Do not hesitate to write me back if you have further questions.
Best wishes,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Geert
Top achievements
Rank 1
answered on 27 Feb 2009, 02:40 PM
Thanks admin, this is just what i needed!!
At this way it's possible to keep using all the features of the gridview!!
At this way it's possible to keep using all the features of the gridview!!
0
Geert
Top achievements
Rank 1
answered on 27 Feb 2009, 03:29 PM
this works fine in your demo application, but when I place a dockingmanager on the form and place 2 dockingpanels on it.
When I place the grid in the first and the listbox in the second it isn't working anymore...
When I place the grid in the first and the listbox in the second it isn't working anymore...
0
Geert
Top achievements
Rank 1
answered on 03 Mar 2009, 02:09 PM
is there a way to get the child control of a documentpanel? The getelementatpoint is not working when the controle is on a documentpanel...
0
Hi Geert,
Thank you for contacting me back.
If you want to use the DockingManager component you need to modify the method that computes the mouse coordinates in the following way:
The code above calls the PointToClient function on the dock panel where the grid is placed.
Do not hesitate to write me back if you have further questions.
Greetings,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for contacting me back.
If you want to use the DockingManager component you need to modify the method that computes the mouse coordinates in the following way:
private void radGridView1_DragDrop(object sender, DragEventArgs e) |
{ |
RadListBoxItem itemToDrop = (RadListBoxItem)e.Data.GetData(typeof(RadListBoxItem)); |
// Point point = PointToClient(new Point(e.X, e.Y)); |
Point point = this.dockPanel1.PointToClient(new Point(e.X, e.Y)); |
point.X -= this.radGridView1.Location.X; |
point.Y -= this.radGridView1.Location.Y; |
RadElement element = this.radGridView1.ElementTree.GetElementAtPoint(point); |
if (element is GridDataCellElement) |
{ |
((GridDataCellElement)element).ColumnInfo.HeaderText = "New Caption"; |
} |
} |
The code above calls the PointToClient function on the dock panel where the grid is placed.
Do not hesitate to write me back if you have further questions.
Greetings,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.