PDA

View Full Version : Formatting DataGrids


TheDude
12-07-2003, 03:31 PM
Here is an example of formatting the column name and widths.


Private Sub Findbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Findbtn.Click
Try
' Creat a SQL string
Dim sqlStr As String
If valuechkbx.Checked = True Then
sqlStr = "SELECT infapplication.executablename as Client, infsection.name as Section," & _
"infparameter.name as Param, infparameter.[value] as Value FROM infapplication INNER JOIN " & _
"infsection ON infapplication.ID = infsection.applicationID INNER JOIN " & _
"infparameter ON infsection.ID = infparameter.sectionID " & _
"where infparameter.value LIKE '%" & searchinput1.Text & "%' order by Client"
Else
sqlStr = "SELECT infapplication.executablename as Client, infsection.name as Section," & _
"infparameter.name as Param, infparameter.[value] as Value FROM infapplication INNER JOIN " & _
"infsection ON infapplication.ID = infsection.applicationID INNER JOIN " & _
"infparameter ON infsection.ID = infparameter.sectionID " & _
"where infparameter.name LIKE '%" & searchinput1.Text & "%' order by Client"
End If

' Create data adapter object
Dim da As SqlDataAdapter = New SqlDataAdapter(sqlStr, dbconnect)
' Create a dataset object and fill with data using data adapter's Fill method

Dim ds As DataSet = New DataSet
da.Fill(ds, "infparameter")

ds.Tables(0).Columns.Item(0).ColumnName = "Client"
ds.Tables(0).Columns.Item(1).ColumnName = "Section"
ds.Tables(0).Columns.Item(2).ColumnName = "Param"
ds.Tables(0).Columns.Item(3).ColumnName = "Value"

Dim ts As New DataGridTableStyle
ts.MappingName = "infparameter"
DataGrid1.TableStyles.Clear()
DataGrid1.TableStyles.Add(ts)
DataGrid1.DataSource = ds.Tables(0)
ts.GridColumnStyles(0).Width = 60
ts.GridColumnStyles(1).Width = 100
ts.GridColumnStyles(2).Width = 275
ts.GridColumnStyles(3).Width = 275

Call ModFunc.logfile("-------Looking for " & searchinput1.Text & "in Infparameter " & Now() & vbCrLf)

'MessageBox.Show("This is all I found for your search string " & searchinput1.Text & ".", msggood.ToString(), MessageBoxButtons.OK)

Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), msgbad.ToString(), MessageBoxButtons.OK)
End Try

End Sub

avaxork09
12-22-2009, 08:56 PM
I need to make the items in a list box more than one line. I have tried formatting the text field associated with the object like so:

listitem.textField.multiline = true;

no love.

var textformat:TexFormat = TextFormat;
textformat.multiline = true;

OR

textformat.wordWrap = true;

listitem.setStyle"textFormat", textformat;

no love. This is not available for this object by the way.

So if you know how to do this, I would love to know too.