private void clstElement_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) { BindingListView <EntityElementTemplate> source = clstElement.DataSource as BindingListView <EntityElementTemplate>; if (source != null) { EntityElementTemplate objElementTemplate = source.FirstOrDefault(t => t.serno.ToString() == e.Item.ToString()); if (objElementTemplate.linkSerno != null) { e.Appearance.ForeColor = Color.Blue; //e.Appearance.Font = new Font("宋体", 10.5f, FontStyle.Bold); } } }
/// <summary> /// Demo get only changed fields /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { var item = view.FirstOrDefault(c => c.CustomerIdentifier == 4); var entry = context.Entry(item); if (entry.State != EntityState.Modified) { return; } //CheckIfDifferent(entry); var originalEntity = context.Customers.AsNoTracking() .FirstOrDefault(me => me.CustomerIdentifier == item.CustomerIdentifier); Console.WriteLine(); foreach (var propertyName in entry.CurrentValues.PropertyNames) { //Console.WriteLine("Property Name: {0}", propertyName); //get original value var orgVal = entry.OriginalValues[propertyName]; //Console.WriteLine(" Original Value: {0}", orgVal); //get current values var curVal = entry.CurrentValues[propertyName]; //Console.WriteLine(" Current Value: {0}", curVal); if (!orgVal.Equals(curVal)) { Console.WriteLine($"{propertyName} -> {orgVal} - {curVal}"); } } }