الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

CurrencyManager أريد شرح على

مغلق
بدأه jkalboneh في 14 ديسمبر 2004 · 1 رد · 1,452 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع
CurrencyManager Class  [Visual Basic]See Also
CurrencyManager Members | System.Windows.Forms Namespace | BindingsCollection | BindingContext | Binding | CurrencyManager Members (Visual J# Syntax) | Managed Extensions for C++ Programming Requirements
Namespace: System.Windows.Forms
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)Language
C#

C++

JScript

Visual Basic

Show All
Manages a list of Binding objects.
For a list of all members of this type, see CurrencyManager Members.
System.Object
   System.Windows.Forms.BindingManagerBase
      System.Windows.Forms.CurrencyManager
[Visual Basic]
Public Class CurrencyManager
   Inherits BindingManagerBase
[C#]
public class CurrencyManager : BindingManagerBase
[C++]
public __gc class CurrencyManager : public BindingManagerBase
[JScript]
public class CurrencyManager extends BindingManagerBase
Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
Remarks
The CurrencyManager derives from the BindingManagerBase class. Use the BindingContext to return either a CurrencyManager or a PropertyManager. The actual object returned depends on the data source and data member passed to the Item property of the BindingContext. If the data source is an object that can only return a single property (instead of a list of objects), the type will be a PropertyManager. For example, if you specify a TextBox as the data source, a PropertyManager will be returned. If, on the other hand, the data source is an object that implements IList, IListSource, or IBindingList, a CurrencyManager will be returned.
The Current property returns the current item in the underlying list. To change the current item, set the Position property to a new value. The value must be greater than 0, and must be less than the value of the Count property.
If the underlying data source implements the IBindingList interface, and the AllowNew property is set to true, you can use the AddNew method.
Example
[Visual Basic, C#, JScript] The following example binds a TextBox control to a column in a DataTable, gets the CurrencyManager for the binding, and sets its position.
[Visual Basic] 
' Place the next line into the Declarations section of the form.
 Private myCurrencyManager As CurrencyManager

 Private Sub BindControl(myTable As DataTable)
    ' Bind a TextBox control to a DataTable column in a DataSet.
    TextBox1.DataBindings.Add("Text", myTable, "CompanyName")
    ' Specify the CurrencyManager for the DataTable.
    myCurrencyManager = CType(me.BindingContext(myTable), CurrencyManager)
    ' Set the initial Position of the control.
    myCurrencyManager.Position = 0
 End Sub

 Private Sub MoveNext(myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Position = myCurrencyManager.Count - 1 Then 
       MessageBox.Show("You're at end of the records")
    Else
       myCurrencyManager.Position += 1
    End If
 End Sub

 Private Sub MoveFirst(myCurrencyManager As CurrencyManager)
    myCurrencyManager.Position = 0
 End Sub

 Private Sub MovePrevious(myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Position = 0 Then
       MessageBox.Show("You're at the beginning of the records.")
    Else
       myCurrencyManager.Position -= 1
    End if
 End Sub

 Private Sub MoveLast(myCurrencyManager As CurrencyManager)
    myCurrencyManager.Position = myCurrencyManager.Count - 1
 End Sub

تم تعديل هذه المشاركة بواسطة walcom في 14 ديسمبر 2004 في 16:15

#2

اخي الكريم اسف على اختصار الشرح

ال CurrencyManager هو مؤشر للسجلات في قاعدة البيانات

ان تقوم بتعريفها اولا

Private myCurrencyManager As CurrencyManager

ومن ثم في حدث Load

يجب عليك ان تقوم بتعبئة DataSet بامر Fill

ومن ثم تكتب الكود التالي

myCurrencyManager =Me.BindingContext(DataSet, "TableName")
myCurrencyManager.Position = 0

ووضعنا الموشر للسجل الاول

طبعا هذا الكود اختصار من ان تكتب

للسجل الاول

Me.BindingContext(DataSet, "TableName).Position = 0

هذا والله اعلم

هذا الموضوع مغلق.

مواضيع مشابهة