or
| DragDropService dragDrop = dockManager.GetService<DragDropService>(); |
| dragDrop.DragDropMode = DragDropMode.Preview; |
| dragDrop.PreviewDockPosition += new DragDropDockPositionEventHandler(dragDrop_PreviewDockPosition); |
| dragDrop.Starting += new StateServiceStartingEventHandler(dragDrop_Starting); |
| dragDrop.AllowedStates = AllowedDockState.All & ~AllowedDockState.TabbedDocument; |
| private void Form1_Load(object sender, EventArgs e) |
| { |
| radGridView1.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; |
| radGridView1.ShowGroupPanel = false; |
| radGridView1.MasterGridViewTemplate.EnableGrouping = false; |
| radGridView1.MasterGridViewTemplate.AllowAddNewRow = false; |
| GridViewComboBoxColumn col1 = new GridViewComboBoxColumn("Test1", "Test1"); |
| col1.DropDownStyle = RadDropDownStyle.DropDownList; |
| col1.FieldName = "Test1"; |
| col1.DisplayMember = "Test1"; |
| col1.DataType = typeof (int); |
| col1.DataSource = new[] {1, 2, 3}; |
| col1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; |
| radGridView1.Columns.Add(col1); |
| } |
| private void button1_Click(object sender, EventArgs e) |
| { |
| int rowCount = radGridView1.Rows.Count; |
| object[] values = {1}; |
| radGridView1.Rows.Add(values); |
| radGridView1.MasterGridViewInfo.CurrentRow = radGridView1.Rows[rowCount]; |
| radGridView1.Rows[rowCount].Cells["Test1"].BeginEdit(); |
| } |
During the CellBeginEdit event I need to supply a default value for the cell if there is no data in the cell and only during an Edit event. I initialized the default value during the CellEditorInitialized event and all works, the default value appears.
| Private Sub gv_CellEditorInitialized(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gv.CellEditorInitialized |
| If TypeOf gv.ActiveEditor Is RadTextBoxEditor Then |
| gv.ActiveEditor.Value = IIf(object.Data= 0, "",object.Data) |
| End If |
| End Sub |
| If IsNumeric(e.Value.ToString) Then |
| object.data = e.Value |
| End If |