We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

DataBinding

Thread ID:

Created:

Updated:

Platform:

Replies:

69770 Nov 12,2007 05:32 AM Nov 12,2007 03:52 PM Windows Forms 4
loading
Tags: GridControl
Thanvir Hussain
Asked On November 12, 2007 05:32 AM

Hi,
Is it possible for me to databind each cell to a n object. For example, if I have a class MyClass with a MyValue property can I set something like this.

MyClass c = new MyClass();
c.MyValue = "Test";
m_Grid[3, 2].DataSource = c
m_Grid[3, 2].DisplayMember = "MyValue";
m_Grid[3, 2].ValueMember = "MyValue";

thanks
thanvir


Thanvir Hussain
Replied On November 12, 2007 05:37 AM

To add, I am using a GridControl not a databound grid control

>Hi,
Is it possible for me to databind each cell to a n object. For example, if I have a class MyClass with a MyValue property can I set something like this.

MyClass c = new MyClass();
c.MyValue = "Test";
m_Grid[3, 2].DataSource = c
m_Grid[3, 2].DisplayMember = "MyValue";
m_Grid[3, 2].ValueMember = "MyValue";

thanks
thanvir




Jisha Joy [Syncfusion]
Replied On November 12, 2007 09:18 AM

Hi Thanvir,

Thank you for posting query to us.

You can use CellValue property of GridControl to set value to particular cell instead of using DataSource property.
Here is the code snippets:

clsData c1 = new clsData();
c1.Name = "Test";
gridControl1[2, 2].CellValue = c1.Name;

Please refer the sample in the link to illustrate this:
http://websamples.syncfusion.com/samples/Grid.Windows/69770/main.htm

Please try this and let me know if this helps.

Regards,
Jisha


Thanvir Hussain
Replied On November 12, 2007 12:16 PM

Hi,

I don't think you got what I was trying to convey. I was databinding a object to a cell meaning any changes done in the cell should automatically posted back to the object and vice versa.
I am now using the cellvalue property only but everytime my business object changes I have to set back the cellvalue. If I have a winform textbox then I can directly databind the object then all the intractions will be done automatically.
Hope I am clear this time.

thanks
tahnvir

>Hi Thanvir,

Thank you for posting query to us.

You can use CellValue property of GridControl to set value to particular cell instead of using DataSource property.
Here is the code snippets:

clsData c1 = new clsData();
c1.Name = "Test";
gridControl1[2, 2].CellValue = c1.Name;

Please refer the sample in the link to illustrate this:
http://websamples.syncfusion.com/samples/Grid.Windows/69770/main.htm

Please try this and let me know if this helps.

Regards,
Jisha




haneefm [Syncfusion]
Replied On November 12, 2007 03:52 PM

Hi Thanvir ,

The grid does not support simple binding to a single grid cell. But you can get this behavior by using the Control celltype in a grid cell. Below is a forum thread that discuss with the similar issue.

http://www.syncfusion.com/support/forums/message.aspx?&MessageID=59487

Please try this and let me know if this helps.

Best regards,
Haneef


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;