Results 1 to 4 of 4

Thread: [RESOLVED] DataGrid row resizing?

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved [RESOLVED] DataGrid row resizing?

    Couldn't find a way to resizing rows..does anyone knows how is it done?

    currently doing...

    .net2008 Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Cursor.Current = Cursors.WaitCursor
    3.         DataGridEntidades.DataSource = giveDataSet("select CodEntidade AS Cod, NomeEntidade AS Nome, MoradaEntidade AS Morada, Telefone1 AS Contacto from entidades where CodEntidade LIKE '%" & Trim(txtEntidade.Text) & "%' OR NomeEntidade LIKE '%" & Trim(txtEntidade.Text) & "%' OR MoradaEntidade LIKE '%" & Trim(txtEntidade.Text) & "%' OR CPEntidade LIKE '%" & Trim(txtEntidade.Text) & "%' OR Telefone1 LIKE '%" & Trim(txtEntidade.Text) & "%' ORDER BY NomeEntidade")
    4.         'DataGridEntidades.Refresh()
    5.         Cursor.Current = Cursors.Default
    6.     End Sub

    Frustrated attempt resizing columns...
    .net 2008 Code:
    1. Try
    2.             Dim ts As New DataGridTableStyle
    3.             ts.MappingName = "Entidades"
    4.             DataGridEntidades.TableStyles.Clear()
    5.             DataGridEntidades.TableStyles.Add(ts)
    6.             DataGridEntidades.TableStyles("Entidades").GridColumnStyles(1).Width = 10
    7.         Catch ex As Exception
    8.             '
    9.         End Try

    Does anyone has any clue why is this happening?
    Thanks
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: DataGrid row resizing?

    This works for me:-

    Code:
     Dim aGridTableStyle2 As New DataGridTableStyle
                aGridTableStyle2.MappingName = "Source"
    
                Me.dgPermits.RowHeadersVisible = False
                Me.dgPermits.ColumnHeadersVisible = False
                
                
                
                With locationCol1
    	      .MappingName = "Reg No"
    	      .Width = 130
    	      .NullText = ""
    	    End With
    	    
    	    With locationCol2
    	       .MappingName = "Status"
    	       .Width = 80
                   .NullText = ""
               End With
               With locationCol3
                   .MappingName = "PermitZone"
                   .Width = 0
                  .NullText = ""
               End With
                
                
                 With aGridTableStyle2.GridColumnStyles
    	                    .Add(locationCol1)
    	                    .Add(locationCol2)
    	                    .Add(locationCol3)
                 End With
                 
                dgPermits.TableStyles.Add(aGridTableStyle2)
                dgPermits.Font = gridFont
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: DataGrid row resizing?

    Atm i can't test, will do in a few hours...the phone is on bat charge :/
    Will it work using datasource?
    Thanks for the reply
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  4. #4

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: DataGrid row resizing?

    It did work, here's the full code for others if searching...

    vb Code:
    1. Try
    2.             Dim aGridTableStyle2 As New DataGridTableStyle
    3.             Dim locationCol1 As New DataGridTextBoxColumn
    4.             Dim locationCol2 As New DataGridTextBoxColumn
    5.             Dim locationCol3 As New DataGridTextBoxColumn
    6.             Dim locationCol4 As New DataGridTextBoxColumn
    7.  
    8.             aGridTableStyle2.MappingName = myDataset.ToString
    9.  
    10.             Me.DataGridEntidades.RowHeadersVisible = False
    11.             Me.DataGridEntidades.ColumnHeadersVisible = True
    12.  
    13.             With locationCol1
    14.                 .MappingName = "Cod"
    15.                 .HeaderText = "Cod"
    16.                 .Width = 44
    17.                 .NullText = ""
    18.             End With
    19.  
    20.             With locationCol2
    21.                 .MappingName = "Nome"
    22.                 .HeaderText = "Empresa"
    23.                 .Width = Screen.PrimaryScreen.WorkingArea.Width - locationCol1.Width - 16 '(rotating screen...i set 16 in hardcode because i couldn't find a way to know what's the scrollbar width, this might need some tweek)
    24.                 .NullText = ""
    25.             End With
    26.             With locationCol3
    27.                 .MappingName = "Morada"
    28.                 .HeaderText = "Morada"
    29.                 .Width = -1
    30.                 .NullText = ""
    31.             End With
    32.             With locationCol4
    33.                 .MappingName = "Contacto"
    34.                 .HeaderText = "Contacto"
    35.                 .Width = -1
    36.                 .NullText = ""
    37.             End With
    38.  
    39.             With aGridTableStyle2.GridColumnStyles
    40.                 .Add(locationCol1)
    41.                 .Add(locationCol2)
    42.                 .Add(locationCol3)
    43.                 .Add(locationCol4)
    44.             End With
    45.  
    46.             With DataGridEntidades
    47.                 .BackColor = Color.AliceBlue
    48.                 .BackgroundColor = Color.AliceBlue
    49.                 .GridLineColor = Color.RoyalBlue
    50.                 .HeaderBackColor = Color.SteelBlue
    51.                 .SelectionBackColor = Color.SteelBlue
    52.                 .SelectionForeColor = Color.Red
    53.             End With
    54.  
    55.             DataGridEntidades.TableStyles.Clear()
    56.             DataGridEntidades.TableStyles.Add(aGridTableStyle2)
    57.         Catch ex As Exception
    58.             '
    59.         End Try

    myDataset is a DataTable

    Thanks for the help Pete ( again )
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width