private void grid_CommittingNewRow(object sender, DataGridEndingNewRowEventArgs e)
        {
            txtMsg.Text = "";
            Product product = e.NewRow.DataItem as Product;

            if (string.IsNullOrEmpty(product.ProductNumber))
            {
                e.Cancel          = true;
                txtMsg.Foreground = new SolidColorBrush(Colors.Red);
                txtMsg.Text       = "You must enter the product number.";
            }
        }
 private void grid_CommittingNewRow(object sender, DataGridEndingNewRowEventArgs e)
 {
     txtMsg.Text = "";
     Product product = e.NewRow.DataItem as Product;
     if (string.IsNullOrEmpty(product.ProductNumber))
     {
         e.Cancel = true;
         txtMsg.Foreground = new SolidColorBrush(Colors.Red);
         txtMsg.Text = "You must enter the product number.";
     }
 }
 private void grid_CancelingNewRow(object sender, DataGridEndingNewRowEventArgs e)
 {
     txtMsg.Text = "";
 }
 private void grid_CancelingNewRow(object sender, DataGridEndingNewRowEventArgs e)
 {
     txtMsg.Text = "";
 }
        private void gridControl1_CommittingNewRow(object sender, DataGridEndingNewRowEventArgs e)
        {
            //MessageBox.Show("Datagrid new row commintting.");

            Type classtype = (Data as VirtualListDynamic).RowClassType;

            //storing refrence of current row class object so that is can be used later while
            //CommittedNewRow event to add new row to UI grid.
            rowclassobject = gridControl1.CurrentRow.DataItem;

            //Also create a rowdata array from above object that can be used to pass
            // to R for creating new row in R data frame also.
            PropertyInfo[] properties = classtype.GetProperties();
            int propcount = properties.Length;
            string[] strrowdata = new string[propcount];
            object colstr=null;
            try
            {
                for (int i = 0; i < propcount; i++)
                {
                    colstr = properties[i].GetValue(rowclassobject, null);
                    if (colstr != null)
                    {
                        strrowdata[i] = colstr.ToString();
                    }
                    else
                    {
                        strrowdata[i] = string.Empty;// or NA or NaN
                    }
                }
            }
            catch (Exception ex)
            {
                logService.WriteToLogLevel("Error reading values from new row: ", LogLevelEnum.Error);
                logService.WriteToLogLevel(ex.Message, LogLevelEnum.Error);
            }
            //using strrowdata create something like c(4,2, "Male", 34, "Good") for passing as an argument in R call
            StringBuilder sb = new StringBuilder("c(");
            string comma = ","; // for separating diff values
            double temp;
            for (int i = 0; i < strrowdata.Length; i++)
            {
                if (i + 1 == strrowdata.Length) //for last item comma is not required.
                    comma = string.Empty;

                if (Double.TryParse(strrowdata[i], out temp))//if  its number
                {
                    sb.Append(strrowdata[i] + comma);
                }
                else//its string, put quotes around
                {
                    sb.Append("'"+strrowdata[i]+"'" + comma);
                }
            }
            sb.Append(")"); //add closing round bracket.

            if (sb.Length > 0)
            {
                newrowdata = sb.ToString();
            }
            
        }
 private void variableGrid_CommittingNewRow(object sender, DataGridEndingNewRowEventArgs e)
 {
 }