Data Grid

Hi!

May i know how to bind data into data grid.. i'm sorry to ask such a simple question but i really duno how to bind it..




Answer this question

Data Grid

  • Brent Cray

    ok.. then i think shall not include picture box in datagrid..

    thanks a lot..



  • Steele

    i use data grid. currently i'm using VS2003.



  • Steve Hittle

    i'm using datagrid. i use VS 2003 to write program.

  • PaulDrda

    Hi

    If it is Web Application you can do it.

    But if it is Windows Appllication then this is the Problem.

    DataGrid control don't have PictureBox column Style.If you need, you can cutomise DataGridTextBoxColumn style. I have done it long before. But it will take more time and on top of that performance also less.

    So, Better you can think for some other way (not DataGridPictureBoxColumn Style). I would suggest you dont put picture in datagrid column. If you realy want, try to customice DataGridColumnStyle and DataGridCellStyle (Both Needed) for ypur application purpose.(It may need more time).



  • Boske

    Hi,

    may i know whether can i customize the data grid column width according to the text in each column. for an instance, my text length is 100 and i wan to make the column width edual to 100. this means that certain column will have different width.



  • Devo64

    Actually now i have successfully display all data in the datagrid already.

    but i wish to add a column in the datagrid to display a small image.. so is that possible for me to add a picture box in a column in the datagrid



  • davidemile

    Hi

    you can do it.put this method in your form.

    Private Sub FormatDataGrid(ByVal ObjDataTable As DataTable)

    'Format The Scat DataGrid Style

    Try

    If IsNothing(ObjDataTable) Then

    'Check The DataTable for Nothing

    Exit Sub

    ElseIf ObjDataTable.Columns.Count = 0 Then

    'Check The Datatable Having Valid Columns

    Exit Sub

    End If

    DataGrid1.DataSource = ObjDataTable.DefaultView

    'Assign The DataTable to the DataGrid

    'Create A DataGridTableStyle Start

    Dim _dgtsTemp As New DataGridTableStyle

    Dim _intColumn As Integer

    _dgtsTemp.MappingName = ObjDataTable.TableName

    'Create A DataGridTextBoxColumn Start

    For _intColumn = 0 To ObjDataTable.Columns.Count - 1

    'Excutes the loop for every column in the datatable\

    Dim _dgtbcTemp As New DataGridTextBoxColumn

    'Create Columnstyle from DataGridColumnStyleScat

    _dgtbcTemp.MappingName = ObjDataTable.Columns(_intColumn).ColumnName()

    'Set the column name of the Column Style

    _dgtbcTemp.HeaderText = ObjDataTable.Columns(_intColumn).ColumnName()

    'Set the Column Header Text

    _dgtsTemp.GridColumnStyles.Add(_dgtbcTemp)

    'Add the Column style to the Datagrid Table style

    Next

    DataGrid1.TableStyles.Clear()

    'Clear the existing table styles if present.

    DataGrid1.TableStyles.Add(_dgtsTemp)

    'Add The customised Table style to datagrid Table style collection

    Catch ex As Exception

    'IF Exeption raisedThrough the exception

    Throw ex

    End Try

    End Sub

    And call this form with DataTable

    then if you want to change the Third column width =100

    then put this code

    DataGrid1.TableStyles(0).GridColumnStyles(2).Width = 100

    'GridColumnStyles(2) :2 is column Index



  • Ricky A Jones

    Are you using a data grid or a datagridview

    Datagridview came with VB Express / 2005


  • Data Grid