Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi can i hide columns in array?


normally;
.Columns(3).Visible = False
.Columns(4).Visible = False
.Columns(5).Visible = False


i want like ;

.Columns(3,4,5).Visible = False

What I have tried:

.Columns(3,4,5).Visible = False
Posted
Updated 13-May-20 4:46am
Comments
Maciej Los 14-May-20 2:08am    
What kind of columns: DataTable, Grid, DataGridView?
What framework: WinForm, ASP.NET, WPF?

If it's standard DataGridView try this

VB
Private Sub HideDGVColumns(ColumnArr() As Integer, DGV as DataGridView ) 
    For i As Integer = 0 To ColumnArr.Length-1 
        DGV.Columns(ColumnArr(i) ) .Visible = False
    Next 
End Sub

' To use  with DataGridView1
HideDGVColumns(New Integer(){3,4,5},DataGridView1) 
 
Share this answer
 
v2
Comments
Member 14588284 25-Jul-20 3:10am    
Hi again :)

İn this codes
can i get {3,4,5} values from textbox text?

Hide   Copy Code
HideDGVColumns(New Integer(){3,4,5},DataGridView1) HideDGVColumns(New Integer(){textbox1.text},DataGridView1) 
i tried this but of course not worked


c_carkod=3
c_sno=4
c_tno=5
.
.



i must add a note:
my textbox.text is "c_carkod,c_sno,c_tno,....."
this means :"3,4,5,...."
Check the documentation for the control that you are using to see if the second version will work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900