Download source-117kb
As shown in the preceding two figures, the left side is the winform datagridview and the right side is the WPF DataGrid (encapsulated as the custom control dragdatagrid and loaded in winform through the WPF elementhost ). You can drag and drop the rows to sort them. In addition, you can drag data from the winform datagridview to the WPF DataGrid. Therefore, the drag and drop methods between two dview are similar to those between two DataGrid. The above controls disable the sort function and set the allowdrop attribute to true.
- Drag and Drop rows in winform dview
- Use the drag & Drop Series Method to pass the pulled row data through E. Data. getdata (). The movement of tippanel is controlled in mousemove.
- Row dragging of the WPF DataGrid
- Click here to use the method on a foreigner's blog
- Drag between the datagridview and DataGrid
- The following code reports a com exception in the dragenter method of the WPF DataGrid:
1 DataGridViewRow curRow = (DataGridViewRow)e.Data.GetData(typeof(DataGridViewRow));
Therefore, a data serialization class dataserializer is encapsulated to serialize the databounditem of the drag-and-drop row of the current dview to the string type. In WPF, use the following code to obtain the string and then deserialize it as an instance object.
string strRow = (string)e.Data.GetData(DataFormats.StringFormat);
Animal aimAnimal = (Animal)DataSerializer.DeserializeObject(strRow);
- Tipcontrol & popup
- In winform, A tipcontrol usercontrol is used to display the row information during the Drag and Drop Process.
- Use popup in WPF to display the current row Information
- Press ctrl and drag the row to assign a value to the data row.
- Problems: there are still some bugs and deficiencies. You can learn from them for reference only.