Arijeet Ghosh

Arijeet Ghosh

  • NA
  • 210
  • 37.6k

why's the anchor property of the dgv doesn't work with arrays ?

Feb 19 2021 9:15 AM
i have set the anchor property of datagridview to top,left,bottom,right and scroll bars to both and changed nothing in the property of dgv and then used arrays to create columns [by just dgv.columns.add(arr[r,c]);
the columns were created uptill this was fine
 
but when used with large deta suppose just 50 columns and 100 rows it collapsed . the dgv exceeded the borders of the form . why ? i have also coded the hscrollbar like this
 
in the form class i just added the arrar to the dgv and wrote
  1. class form ()  
  2. {  
  3.        hscrollbar hb=new hscrollbar();  
  4.       private void form_load()  
  5.       {  
  6.             
  7.           //added the array to the datagridview by  
  8.             string arr=field [r,c];  // the values of field is taken already and that's okay .....  
  9.             dgv.columns.add( arr,arr);  
  10.             hb.scroll +=hb_scroll;  
  11.       }  
  12.       void hb_scroll()  
  13.       {  
  14.            for(int i=0;i<dgv.columncount;i++)  
  15.            {    dgv.columns[i].headertext= field[r,c];   }      
  16.  }  

Answers (3)