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.

this.gridDataBoundGrid1

Thread ID:

Created:

Updated:

Platform:

Replies:

120034 Aug 25,2015 12:02 PM Oct 5,2015 11:48 AM Windows Forms 9
loading
Tags: GridDataBoundGrid(Classic)
Gregory Pe
Asked On August 25, 2015 12:02 PM


please help

I am sending the program code

solution on the left side wanted to move to syncfusio


how to do
this using
this.gridDataBoundGrid1   and  integerTextBox1,doubleTextBox1,gridAwareTextBox1,percentTextBox1




Attachment: test002_5568269a.zip

Christopher Issac Sunder K [Syncfusion]
Replied On August 26, 2015 11:36 PM

Hi Grzegorz,

Thank you for your interest in Syncfusion products.

If you want a button in all the cells of grid and that will be shown only on edit mode, you can make use of the below properties to achieve that.,

//Register the cell model -> Syncfusion.GridHelperClasses.Windows.dll

RegisterCellModel.GridDataBoundCellType(this.gridDataBoundGrid1, CustomCellTypes.ButtonEdit);

this.gridDataBoundGrid1.TableStyle.CellType = CustomCellTypes.ButtonEdit.ToString();


//show the buttons only on current cell editing.

this.gridDataBoundGrid1.TableStyle.ShowButtons = Syncfusion.Windows.Forms.Grid.GridShowButtons.ShowCurrentCellEditing;


this.gridDataBoundGrid1.CellButtonClicked += gridDataBoundGrid1_CellButtonClicked;



Modified Sample: test002


Regarding Syncfusion text boxes in the right side, you can use the same methodology used in MS textboxes.

Please let me know if you have any other concerns.

Regards,
Christo

Gregory Pe
Replied On August 28, 2015 11:37 AM

It is better but after changing positions bottom is invisible but still working
by clicking, for example, id 9


second question
  or if you change the width of the mouse you can be saved to a file such as XML gridDataBoundGrid1 settings.
To the next time you read the last set gridDataBoundGrid1

settings:   -HeaderText, ReadOnly, Position, Width, Hidden, MappingName ,


Attachment: test002_2ff00707.zip

Adhikesevan Kothandaraman [Syncfusion]
Replied On August 31, 2015 01:23 PM

Hi Grzegorz,

Thank you for your update.

Query 1
after changing positions bottom is invisible but still working
To enable the button click only on current cell in edit mode, it can be achieved by using the below code snippet,

Code Snippet:

void gridDataBoundGrid1_CellButtonClicked(object sender, Syncfusion.Windows.Forms.Grid.GridCellButtonClickedEventArgs e)

{

//Disable the button click

if (this.gridDataBoundGrid1.Binder.CurrentRowIndex != e.RowIndex)

return;

MessageBox.Show(this.gridDataBoundGrid1[e.RowIndex, e.ColIndex].Text);

}

Query 2
How to serialize the contents of the grid to xml file.
If you want to save the settings of the file to an xml document. You can save it by using the SaveSoap method. Please refer the below code snippet,
Code snippet:
//To save the grid settings as the xml data.
this.gridDataBoundGrid1.Model.SaveSoap("Soap.xml");    

We would also like to suggest you to refer the below KnowledgeBase document. Which may help you to manually configure the xml document.
KB Link:
http://www.syncfusion.com/kb/723/is-there-an-effective-way-to-persist-the-state-of-expanded-collapsed-row-when-we-re-bind-the

Sample:
http://www.syncfusion.com/downloads/support/forum/120034/ze/test002_-_Copy1044218157

Please let me know if I have misunderstood your query.

Regards,
Adhi.

Gregory Pe
Replied On September 26, 2015 11:14 AM

hI Adhi.

//To save the grid settings as the xml data.

this.gridDataBoundGrid1.Model.SaveSoap("Soap.xml");


I created tables:
Create Table [UserTable] (ID int, [UserObject] xml)

How to save a file Soap.xml  to a table UserTable
and
how to read
 
the table UserTable


Adhikesevan Kothandaraman [Syncfusion]
Replied On September 28, 2015 12:11 PM

Hi Grzegorz,

Thanks for your update.

If you want to save the xml file to the data table and read, it can be achieved by using the SaveSoap and LoadSoap methods. Please refer to the following code example.

Code Example:

public DataTable CreateDataTable()

{

    DataTable dt = new DataTable("Xml-Data");

    dt.Columns.Add(new DataColumn("id", typeof(int)));

    dt.Columns.Add(new DataColumn("xml", typeof(object)));

    return dt;
}

//Serialization using Soap Formatter

FileDialog dlg = new SaveFileDialog();

dlg.Filter = "Soap files (*.soap)|*.soap|All files (*.*)|*.*";

if (dlg.ShowDialog() == DialogResult.OK)
{

//Save the grid model object to a stream in SOAP format

this.gridDataBoundGrid1.Model.SaveSoap(dlg.FileName);

XmlTable = this.CreateDataTable();

DataRow row = XmlTable.NewRow();

row[0] = 1;

row[1] = dlg.FileName;//Add the xml file to the data table
XmlTable.Rows.Add(row);
}

//To load the xml file from the datatable
this.gridDataBoundGrid1.Model = GridDataBoundGridModel.LoadSoap(this.XmlTable.Rows[0].ItemArray[1].ToString());

Note:
Since the GridDataBoundGrid is populated with a bound source, the values of the cells will not be stored in the xml file. If you want to get including values of the cells, please refer to the below dashboard sample, it will shows how to serialize and de-serialize the contents of the grid.
Dashboard sample:
<InstalledLocation>\Syncfusion\EssentialStudio\<VersionNo>\Windows\GridDataBound.Windows\Samples\Serialization\Serialize Grid Data Bound Grid Demo\CS

Regards,
Adhi


Gregory Pe
Replied On September 28, 2015 02:40 PM

hI Adhi.

thank you
 but not the contents of the file name

 I would save stream, // (contents)
 
and  methods SaveSoap and LoadSoap to strem in table

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 29, 2015 01:55 PM

Hi Perrie,

Thanks for your update.

If you want to Save the content of the grid as stream, please refer to the following sample, it will show how to stream the contents of the grid.

Sample:
http://www.syncfusion.com/downloads/support/forum/120034/ze/CS31334777

Regards,
Adhi

Gregory Pe
Replied On September 29, 2015 02:59 PM


hI Adhi.




Now I have:
......................................................................................
 public void initializegrid_01()
        {
            if (File.Exists("MySizes.bin"))
            {
                try
                {
                    IFormatter formatter = new BinaryFormatter();
                    Stream stream = new FileStream("MySizes.bin", FileMode.Open, FileAccess.Read, FileShare.None);
                    try
                    {
                        this.gridDataBoundGrid1.BeginUpdate();
                        //handle the mappingnames
                        GridBoundColumnsCollection col = (GridBoundColumnsCollection)this.gridDataBoundGrid1.GridBoundColumns.Clone();
                        if (col.Count == 0)
                            col = this.gridDataBoundGrid1.Binder.InternalColumns;
                        string[] a = (string[])formatter.Deserialize(stream);
                        this.gridDataBoundGrid1.GridBoundColumns.Clear();
                        foreach (string s in a)
                        {
                            GridBoundColumn c = col[s];
                            this.gridDataBoundGrid1.GridBoundColumns.Add(c);
                        }
                        this.gridDataBoundGrid1.Model.ColWidths.Dictionary =
                        (Syncfusion.Windows.Forms.Grid.GridRowColSizeDictionary)formatter.Deserialize(stream);
                    }
                    finally
                    {
                        this.gridDataBoundGrid1.EndUpdate();
                        this.gridDataBoundGrid1.Refresh();
                        stream.Close();
                    }
                }
                catch (Exception ex)
                { }
            }

        }




void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                //Serialize out the row heights & column widths
                IFormatter formatter = new BinaryFormatter();
                Stream stream = new FileStream("MySizes.bin", FileMode.Create, FileAccess.Write, FileShare.None);
                //Handle the mapping names
                GridBoundColumnsCollection col = (GridBoundColumnsCollection)this.gridDataBoundGrid1.GridBoundColumns;
                if (col.Count == 0)
                    col = this.gridDataBoundGrid1.Binder.InternalColumns;
                int nCols = col.Count;
                string[] a = new string[nCols];
                int i = 0;
                foreach (GridBoundColumn c in col)
                    a[i++] = c.MappingName;
                formatter.Serialize(stream, a);
                formatter.Serialize(stream, this.gridDataBoundGrid1.Model.ColWidths.Dictionary);
                stream.Close();
            }
            catch (Exception ex)
            { }

        }

......................................................................................


I would like to
record
after closing the Form  the parameters (width, order visibility, etc.) gridDataBoundGrid1 format xml in sql (not in the file MySizes.bin  )

 and I read from the database sql Form parameters of format xml from sql


I want to skip file MySizes.bin   -  the settings stored in the SQL database
Table [UserTable] (ID int, [UserObject] xml)

ID = id Form (Form1= 1,
Form2= 2,etc.) -
UserObject = (xml format strem setings Form gridDataBoundGrid1 parameters , properties --MySizes.bin  )






Adhikesevan Kothandaraman [Syncfusion]
Replied On October 5, 2015 11:48 AM

Hi Grzegorz,

Regret for the delay caused.

There is no direct support to store the xml values in a table. The SaveSoap and the LoadSoap methods are used to store only the model of the GridDataBoundGrid. Since the predefined tags are only stored in the xml file. We can only load the model(style of the table to the xml file) to the grid.

Regards,
Adhi

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.

;