Category / Section
How to save changes of the cell to the data base of DateTimePicker in WinForms GridControl?
1 min read
Save the changes to the database
In order to save the changes in database for datetimepicker cell type, GridControl has support to save the cell values using SaveCellInfo event. Using e.ModifyType you can check the status of the cell value like whether it is modified or newly added.
C#
//MonthCalendar celltype this.gridControl1[1, 2].Text = "MonthCalendar"; this.gridControl1.ColWidths[2] = 100; this.gridControl1[2, 2].CellType = GridCellTypeName.MonthCalendar; //Event Handler Me.gridControl1.SaveCellInfo += gridControl1_SaveCellInfo void gridControl1_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e) { //Saves the modified value in a temp variable. string temp = e.Style.CellValue.ToString(); }
VB
'MonthCalendar celltype Me.gridControl1(1, 2).Text = "MonthCalendar" Me.gridControl1.ColWidths(2) = 100 Me.gridControl1(2, 2).CellType = GridCellTypeName.MonthCalendar 'Event Handler Me.gridControl1.SaveCellInfo += gridControl1_SaveCellInfo Private Sub gridControl1_SaveCellInfo(ByVal sender As Object, ByVal e As GridSaveCellInfoEventArgs) 'Saves the modified value in a temp variable. Dim temp As String = e.Style.CellValue.ToString() End Sub
Screenshot