Git Product home page Git Product logo

winforms-grid-edit-row-server-mode's Introduction

WinForms Data Grid - Edit the focused row in DataLayoutControl in Server Mode

Server Mode does not work if you bind the GridControl and DataLayoutControl to the same collection, and use the DataLayoutControl as the grid's Edit Form, because the CurrencyManager does not manage Server Mode Data Sources. All Server Mode data sources except for XPServerCollectionSource are read-only.

This example handles the FocusedRowChanged event to synchronize the DataLayoutControl's data source (XPBindingSource or BindingSource) with the focused row in the GridControl.

Implementation details

  1. Bind the DataLayoutControl to a data source in the Visual Studio Designer.
  • If your ORM is XPO, add the XPBindingSource component from the toolbox.
    1. Rebuild the project.
    2. Select the XPBindingSource.ObjectClassInfo property in the Properties window, open the drop-down list, and choose an appropriate XPO class.
    3. Assign XPBindingSource to the DataLayoutControl.DataSource property.
  • If your ORM is EF or a different library, add the BindingSource component from the toolbox.
    1. Rebuild the project.
    2. Click the Project > Add New Data Source menu item.
    3. Choose the Object Data Source Type and click Next.
    4. Choose an appropriate class in the list and click Finish.
    5. Assign BindingSource to the DataLayoutControl.DataSource property.
  1. Retrieve data fields.
  2. Select the GridView and subscribe to the FocusedRowChanged event.
  3. Use the e.Row property to obtain a data object that corresponds to the focused row and add it to the data source.

Example: XPBindingSource

private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) {
    XPBindingSource.DataSource = Session.GetLoadedObjectByKey<ServerSideGridTest>(e.Row);
}
Private Sub GridView_FocusedRowObjectChanged(ByVal sender As Object, ByVal e As FocusedRowObjectChangedEventArgs)
    XPBindingSource.DataSource = Session.GetLoadedObjectByKey(Of ServerSideGridTest)(e.Row)
End Sub

Example: BindingSource

private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) {
    object obj = DbContext.ServerSideGridTests.Single(e.Row);
    BindingSource.Clear();
    BindingSource.Add(obj);
}
Private Sub GridView_FocusedRowObjectChanged(ByVal sender As Object, ByVal e As FocusedRowObjectChangedEventArgs)
	Dim obj As Object = DbContext.ServerSideGridTests.Single(e.Row)
	BindingSource.Clear()
	BindingSource.Add(obj)
End Sub

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

winforms-grid-edit-row-server-mode's People

Contributors

iam0k avatar uriahas avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.