BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
private void button4_Click(object sender, System.EventArgs e)
{
GridBoundColumnsCollection columns;
if (gridDataBoundGrid1.Binder.GridBoundColumns.Count == 0)
columns = (GridBoundColumnsCollection) this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
else
columns = (GridBoundColumnsCollection) gridDataBoundGrid1.Binder.GridBoundColumns.Clone();
// Add Column
ds.Tables[0].Columns.Add(new DataColumn("NEW COL",typeof(string)));
GridBoundColumn newColumn = new GridBoundColumn();
newColumn.MappingName = "NEW COL";
columns.Add(newColumn);
this.gridDataBoundGrid1.Binder.GridBoundColumns = columns;
}
This works fine then with 3.2.1.0 but I haven''t tried earlier versions.
Stefan
>Hi Tomas,
>
>Rebinding the grid does not help in this case. To avoid the probem, I have to recreate the grid on run-time. Like :
>
>this.gridRecordNavigationControl1 = new Syncfusion.Windows.Forms.Grid.GridRecordNavigationControl();
> this.gridRecordNavigationControl1.Location = new System.Drawing.Point(32, 48);
> this.gridRecordNavigationControl1.MaxLabel = "of 1000";
> this.gridRecordNavigationControl1.MaxRecord = 1000;
> this.gridRecordNavigationControl1.NavigationBarWidth = 237;
> this.gridRecordNavigationControl1.Size = new System.Drawing.Size(520, 256);
> this.gridRecordNavigationControl1.SplitBars = Syncfusion.Windows.Forms.DynamicSplitBars.Both;
>
>this.gridDataBoundGrid1 = new Syncfusion.Windows.Forms.Grid.GridDataBoundGrid();
> this.gridDataBoundGrid1.DataSource=this.dataSet11.Customers;
> this.gridDataBoundGrid1.VerticalScrollTips=true;
> this.gridDataBoundGrid1.UseListChangedEvent = true;
> this.gridRecordNavigationControl1.Controls.Add(this.gridDataBoundGrid1);
>
>//Add the nav control to the form.
>this.Controls.Add(this.gridRecordNavigationControl1);
> this.gridDataBoundGrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0));
>
>This will certainly work. But I really hope to see a simpler solution.
>
>Regards
>Pua Eng Heng.
>
>
>
>
>>Maybe you have to reset the datasource after adding the new column to the grid.
>>
>>this.grid.BeginUpdate();
>>
>>this.grid.DataSource = null
>>
>>this.grid.Model.ResetVolatileData();
>>
>>// add the column
>>this.grid.DataSource = your datasource;
>>this.grid.Binder.InitializeColumns();
>>
>>this.grid.EndUpdate();
>>
>>That the way how I would like to handle this.
>>
>>Regards,
>>Thomas
> private void button4_Click(object sender, System.EventArgs e)
> {
> GridBoundColumnsCollection columns;
> if (gridDataBoundGrid1.Binder.GridBoundColumns.Count == 0)
> columns = (GridBoundColumnsCollection) this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
> else
> columns = (GridBoundColumnsCollection) gridDataBoundGrid1.Binder.GridBoundColumns.Clone();
>
> // Add Column
> ds.Tables[0].Columns.Add(new DataColumn("NEW COL",typeof(string)));
>
> GridBoundColumn newColumn = new GridBoundColumn();
> newColumn.MappingName = "NEW COL";
> columns.Add(newColumn);
> this.gridDataBoundGrid1.Binder.GridBoundColumns = columns;
> }
>
>
>This works fine then with 3.2.1.0 but I haven''t tried earlier versions.
>
>Stefan
>
>
>>Hi Tomas,
>>
>>Rebinding the grid does not help in this case. To avoid the probem, I have to recreate the grid on run-time. Like :
>>
>>this.gridRecordNavigationControl1 = new Syncfusion.Windows.Forms.Grid.GridRecordNavigationControl();
>> this.gridRecordNavigationControl1.Location = new System.Drawing.Point(32, 48);
>> this.gridRecordNavigationControl1.MaxLabel = "of 1000";
>> this.gridRecordNavigationControl1.MaxRecord = 1000;
>> this.gridRecordNavigationControl1.NavigationBarWidth = 237;
>> this.gridRecordNavigationControl1.Size = new System.Drawing.Size(520, 256);
>> this.gridRecordNavigationControl1.SplitBars = Syncfusion.Windows.Forms.DynamicSplitBars.Both;
>>
>>this.gridDataBoundGrid1 = new Syncfusion.Windows.Forms.Grid.GridDataBoundGrid();
>> this.gridDataBoundGrid1.DataSource=this.dataSet11.Customers;
>> this.gridDataBoundGrid1.VerticalScrollTips=true;
>> this.gridDataBoundGrid1.UseListChangedEvent = true;
>> this.gridRecordNavigationControl1.Controls.Add(this.gridDataBoundGrid1);
>>
>>//Add the nav control to the form.
>>this.Controls.Add(this.gridRecordNavigationControl1);
>> this.gridDataBoundGrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0));
>>
>>This will certainly work. But I really hope to see a simpler solution.
>>
>>Regards
>>Pua Eng Heng.
>>
>>
>>
>>
>>>Maybe you have to reset the datasource after adding the new column to the grid.
>>>
>>>this.grid.BeginUpdate();
>>>
>>>this.grid.DataSource = null
>>>
>>>this.grid.Model.ResetVolatileData();
>>>
>>>// add the column
>>>this.grid.DataSource = your datasource;
>>>this.grid.Binder.InitializeColumns();
>>>
>>>this.grid.EndUpdate();
>>>
>>>That the way how I would like to handle this.
>>>
>>>Regards,
>>>Thomas