有没有办法使用Entity Framework将DataGridView上的各个列绑定到数据库中的表?

时间:2016-08-13 11:01:49

标签: c# winforms entity-framework datagridview

因此,您可以将各种字段绑定到class HeaderColorChanger implements ViewPager.OnPageChangeListener { private ArgbEvaluator argbEvaluator = new ArgbEvaluator(); private View mView; private int[] mColors; HeaderColorChanger(View view, int[] colors) { mView = view; mColors = colors; } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { mView.setBackgroundColor(getHeaderColor(position, positionOffset)); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } private int getHeaderColor(int position, float positionOffset) { if (position == mColors.length - 1) { return mColors[position]; } int startColor = mColors[position]; int endColor = mColors[position + 1]; int color = (int) argbEvaluator.evaluate(positionOffset, startColor, endColor); return color; } } ,这样ComboBox的选定值就会自动填充文本字段。

ComboBox

您可以对var SID = Convert.ToInt32(cbosSID.Text); using (Entities2 db = new Entities2()) { var student = (from a in db.Students where a.SID == SID select a).First(); txtsFName.Text = student.FName; txtsLName.Text = student.LName; txtsPhone.Text = student.Phone; txtsAdd1.Text = student.Add1; txtsAdd2.Text = student.Add2; txtsState.Text = student.State; txtsSuburb.Text = student.Suburb; txtsPost.Text = student.Postcode; dteDOB.Value = student.DOB; dteStart.Value = student.SDate; } 的各个列做同样的事情吗?

我已在DataGridView,学生ID和标记中添加了两列。我尝试使用DataGridView进行此操作,但这并不起作用。

editDataGridView.Columns[course.SID].DataPropertyName = "clmSID";

0 个答案:

没有答案