|
-
Jun 12th, 2010, 02:48 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] DataGrid row resizing?
Couldn't find a way to resizing rows..does anyone knows how is it done?
currently doing...
.net2008 Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Cursor.Current = Cursors.WaitCursor
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")
'DataGridEntidades.Refresh()
Cursor.Current = Cursors.Default
End Sub
Frustrated attempt resizing columns...
.net 2008 Code:
Try
Dim ts As New DataGridTableStyle
ts.MappingName = "Entidades"
DataGridEntidades.TableStyles.Clear()
DataGridEntidades.TableStyles.Add(ts)
DataGridEntidades.TableStyles("Entidades").GridColumnStyles(1).Width = 10
Catch ex As Exception
'
End Try
Does anyone has any clue why is this happening?
Thanks
-
Jun 13th, 2010, 03:37 AM
#2
Frenzied Member
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
-
Jun 13th, 2010, 03:46 AM
#3
Thread Starter
Fanatic Member
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
-
Jun 13th, 2010, 05:46 AM
#4
Thread Starter
Fanatic Member
Re: DataGrid row resizing?
It did work, here's the full code for others if searching...
vb Code:
Try Dim aGridTableStyle2 As New DataGridTableStyle Dim locationCol1 As New DataGridTextBoxColumn Dim locationCol2 As New DataGridTextBoxColumn Dim locationCol3 As New DataGridTextBoxColumn Dim locationCol4 As New DataGridTextBoxColumn aGridTableStyle2.MappingName = myDataset.ToString Me.DataGridEntidades.RowHeadersVisible = False Me.DataGridEntidades.ColumnHeadersVisible = True With locationCol1 .MappingName = "Cod" .HeaderText = "Cod" .Width = 44 .NullText = "" End With With locationCol2 .MappingName = "Nome" .HeaderText = "Empresa" .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) .NullText = "" End With With locationCol3 .MappingName = "Morada" .HeaderText = "Morada" .Width = -1 .NullText = "" End With With locationCol4 .MappingName = "Contacto" .HeaderText = "Contacto" .Width = -1 .NullText = "" End With With aGridTableStyle2.GridColumnStyles .Add(locationCol1) .Add(locationCol2) .Add(locationCol3) .Add(locationCol4) End With With DataGridEntidades .BackColor = Color.AliceBlue .BackgroundColor = Color.AliceBlue .GridLineColor = Color.RoyalBlue .HeaderBackColor = Color.SteelBlue .SelectionBackColor = Color.SteelBlue .SelectionForeColor = Color.Red End With DataGridEntidades.TableStyles.Clear() DataGridEntidades.TableStyles.Add(aGridTableStyle2) Catch ex As Exception ' End Try
myDataset is a DataTable
Thanks for the help Pete ( again )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|