C#绑定在表中的特定行绑定

2023-09-03 07:32:58 作者:丢了少年失了心?

使用C#.NET 2.0,我想一个文本框绑定到我的表的特定行。在示例:

Using c# .net 2.0 , I want to bind a textbox to a specific row of my table. In Example :

 Table Person
 ID NAME PRENOM SPECIAL_CATEGORY
  1 BOB  BOB    mex
  2 AL   AL     tot
  3 PO   PO     pap

我想结合我的文本框的字段名所在的行包含special_categeory ='TOT'。 可能吗?或者我需要建立一个数据行此行的和有约束力的。

I want to bind my textbox on the field name where the row contains special_categeory = 'tot'. Is it possible? or I need to create a Datarow for this row and binding it.

推荐答案

您应该能够通过绑定...

You should be able to bind via...

myNameTextBox.DataBindings.Add( "Text", MyTable, "NAME" );
myPrenomTextBox.DataBindings.Add( "Text", MyTable, "PRENOM" );
mySpecial_CategoryTextBox.DataBindings.Add( "Text", MyTable, "SPECIAL_CATEGORY" );

其实,我只是一个框架,通过滚动的所有控件,如果他们在一个给定的表匹配的列名,他们立即约束自己像上面。

I actually have a framework that scrolls through all controls, and if they match a column name in a given table, they immediately bind themselves like above.

然后,当你滚动网格,它应该也刷新了个人文本控件在表单中了。

Then, when you scroll the grid, it should also refresh the individual text controls in your form too.

 
精彩推荐