I have a form that form has a gridcontrol then when I click column chooser I will add a any column that added column will remove on a gridcontrol when i close the form finally I do not want to lose that added column I hope I can explain what I want to do thank you for everything.
Asked
Active
Viewed 660 times
-3
-
Are you looking to preserve the layout of the GridControl? Have you looked at the Saving and Restoring Layouts documentation? https://documentation.devexpress.com/#windowsforms/CustomDocument772 – Brendon Oct 01 '15 at 20:21
-
Yeap but I have no idea about that – Mustafa Oct 02 '15 at 06:39
-
for example I have a gridcontrol and that gridcontrol has two columns then I will create a column by click columns chooser while the program is running then I want to preserve the layout of the gridcontrol – Mustafa Oct 02 '15 at 06:45
-
Thank you Brendon I solved that – Mustafa Oct 02 '15 at 07:17
-
string filename = "C:\\Users\\WINDOWS 8\\Desktop\\deneme.xml"; private void deneme_Load(object sender, EventArgs e) { gridControl1.ForceInitialize(); gridControl1.MainView.RestoreLayoutFromXml(filename); } private void deneme_FormClosing(object sender, FormClosingEventArgs e) { gridControl1.MainView.SaveLayoutToXml(filename); } – Mustafa Oct 02 '15 at 07:19
1 Answers
0
Please follow this example for customizing the columns :
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="CustomersDataSource"
KeyFieldName="CustomerID" Width="100%">
<Columns>
<dx:GridViewDataColumn FieldName="ContactName" VisibleIndex="0" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="CompanyName" VisibleIndex="1" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="City" VisibleIndex="2" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="Region" Visible="false" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="Country" VisibleIndex="3" ShowInCustomizationForm="true" />
</Columns>
<Templates>
<PagerBar>
<table width="100%">
<tr>
<td style="width: 50%">
<dx:ASPxGridViewTemplateReplacement ID="Pager" runat="server" ReplacementType="Pager" />
</td>
<td align="right">
<dx:ASPxButton ID="btnCustomizationWindow" runat="server" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
AutoPostBack="False" Text="Show/Hide Columns" Width="150px" ClientInstanceName="btnCustomizationWindow"
CssPostfix="Office2010Blue" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
<ClientSideEvents Click="btnCustomizationWindow_Click" />
</dx:ASPxButton>
</td>
</tr>
</table>
</PagerBar>
</Templates>
<Settings ShowGroupPanel="True" />
<SettingsLoadingPanel Mode="ShowOnStatusBar" />
<SettingsBehavior EnableCustomizationWindow="true" />
<SettingsCookies CookiesID="CookiesV1" Enabled="True" StoreColumnsVisiblePosition="true"
StoreColumnsWidth="true" StoreFiltering="False" StoreGroupingAndSorting="False"
StorePaging="False" /><%--This will store the column position and visibility--%>
</dx:ASPxGridView>
Script:
<script type="text/javascript">
function btnCustomizationWindow_Click(s, e) {
if(grid.IsCustomizationWindowVisible())
grid.HideCustomizationWindow();
else
grid.ShowCustomizationWindow();
}
</script>
Note:
If you wish to hide some columns for customization set the property :
ShowInCustomizationForm="false"
Hope this helps.

Ruchi
- 1,238
- 11
- 32
-
-
Please mark the answer correct if it worked for you :) Thank you @Mustafa – Ruchi Oct 07 '15 at 15:13