PlayKid Posted August 16, 2005 Posted August 16, 2005 Dear all, Just wonder is it possible to hide any columns in the datagrid? I have read some books, but they didn't say anything about this issue, but is it possible. Thanks PlayKid Quote
penfold69 Posted August 16, 2005 Posted August 16, 2005 Yes, you need to set the appropriate width in the TableStyle to 0. If you are allowing the DataGrid to create the TableStyle manually, then after you set the Datasource of the datagrid, do: datagrid.TableStyles(0).GridColumnStyles(YourColumnIndex).Width = 0 This will make the width of the column 0, and therefore not visible. If you are creating the tablestyle yourself, simply include the relevant columns in the tablestyle that you wish to display. Any other columsn in the datatable/dataset that are not named in your tablestyle will simply not appear. B. Quote
bri189a Posted August 20, 2005 Posted August 20, 2005 (edited) If your speaking of an ASP.NET datagrid, the easy way would be to: In design mode click on the datagrid, and then open the properties page. For the column you want to hide, uncheck the Visible check box. In code: Me.myDataGrid.Columns(0).Visible = False this.myDataGrid.Columns[0].Visible = False; I'm not sure of the Windows version, but it's probably similiar. At no time should you have to use an integer to represent a visibility state in .NET - at the minimum there will be an enumeration. Edited August 20, 2005 by bri189a Quote
PlayKid Posted August 21, 2005 Author Posted August 21, 2005 Thanks for both of your replies, but I have used another method, here is my code, if there is anyone would like to use as well. ClientDataSet1.Tables("Client").Columns("ClientNo").ColumnMapping = MappingType. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.