Rename Column header of a datagrid

brucelim80

Active member
Joined
Apr 20, 2006
Messages
35
Programming Experience
Beginner
hi all,

Can anyone help me with this problem?

I have a datagrid which bind to a bindingsource (connected to a dataset).
How do i rename the columnheader text and remove some of the columns as well as setting the individual colummn width of the column?

I know you can do these in a datagridview on the properities however i cannot find this option ona datagrid.
i am using a typed dataset and a tableadapter

Code under form designer mode

VB.NET:
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim WorkidLabel As System.Windows.Forms.Label
        Dim resources As System.ComponentModel.ComponentResourceManager = _
New System.ComponentModel.ComponentResourceManager(GetType(personalportal))
        Me.TrackingDB1BindingSource = New System.Windows.Forms.BindingSource(Me.components)
        Me.EcallDataSet = New ecall.ecallDataSet
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.TrackingDB1TableAdapter = New ecall.ecallDataSetTableAdapters.TrackingDB1TableAdapter
        Me.WorkidTextBox = New System.Windows.Forms.TextBox
        Me.MyDataGrid1 = New MyDataGrid.vb.MyDataGrid
        WorkidLabel = New System.Windows.Forms.Label
        CType(Me.TrackingDB1BindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.EcallDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.MyDataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()

        '
        'WorkidLabel
        '
        WorkidLabel.AutoSize = True
        WorkidLabel.Location = New System.Drawing.Point(13, 251)
        WorkidLabel.Name = "WorkidLabel"
        WorkidLabel.Size = New System.Drawing.Size(55, 13)
        WorkidLabel.TabIndex = 2
        WorkidLabel.Text = "Ticket no:"
        '
        'TrackingDB1BindingSource
        '
        Me.TrackingDB1BindingSource.DataMember = "TrackingDB1"
        Me.TrackingDB1BindingSource.DataSource = Me.EcallDataSet
        Me.TrackingDB1BindingSource.Filter = ""
        '
        'EcallDataSet
        '
        Me.EcallDataSet.DataSetName = "ecallDataSet"
        Me.EcallDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
        '
        'Timer1
        '
        Me.Timer1.Interval = 4000
        '
        'TrackingDB1TableAdapter
        '
        Me.TrackingDB1TableAdapter.ClearBeforeFill = True
        '
        'WorkidTextBox
        '
        Me.WorkidTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", _
Me.TrackingDB1BindingSource, "workid", True))
        Me.WorkidTextBox.Location = New System.Drawing.Point(74, 244)
        Me.WorkidTextBox.Name = "WorkidTextBox"
        Me.WorkidTextBox.Size = New System.Drawing.Size(118, 20)
        Me.WorkidTextBox.TabIndex = 3
        '
        'MyDataGrid1
        '
        Me.MyDataGrid1.AlternatingBackColor = System.Drawing.Color.LightGray
        Me.MyDataGrid1.BackColor = System.Drawing.Color.Gainsboro
        Me.MyDataGrid1.BackgroundColor = System.Drawing.Color.Silver
        Me.MyDataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.MyDataGrid1.CaptionBackColor = System.Drawing.Color.LightSteelBlue
        Me.MyDataGrid1.CaptionForeColor = System.Drawing.Color.MidnightBlue
        Me.MyDataGrid1.CaptionText = "Personal Job Portal Queue"
        Me.MyDataGrid1.DataMember = ""
        Me.MyDataGrid1.DataSource = Me.TrackingDB1BindingSource
        Me.MyDataGrid1.FlatMode = True
        Me.MyDataGrid1.Font = New System.Drawing.Font("Tahoma", 8.0!)
        Me.MyDataGrid1.ForeColor = System.Drawing.Color.Black
        Me.MyDataGrid1.GridLineColor = System.Drawing.Color.DimGray
        Me.MyDataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None
        Me.MyDataGrid1.HeaderBackColor = System.Drawing.Color.MidnightBlue
        Me.MyDataGrid1.HeaderFont = New System.Drawing.Font("Tahoma", 8.0!, System.Drawing.FontStyle.Bold)
        Me.MyDataGrid1.HeaderForeColor = System.Drawing.Color.White
        Me.MyDataGrid1.LinkColor = System.Drawing.Color.MidnightBlue
        Me.MyDataGrid1.Location = New System.Drawing.Point(12, 12)
        Me.MyDataGrid1.Name = "MyDataGrid1"
        Me.MyDataGrid1.ParentRowsBackColor = System.Drawing.Color.DarkGray
        Me.MyDataGrid1.ParentRowsForeColor = System.Drawing.Color.Black
        Me.MyDataGrid1.PreferredColumnWidth = 100
        Me.MyDataGrid1.SelectionBackColor = System.Drawing.Color.CadetBlue
        Me.MyDataGrid1.SelectionForeColor = System.Drawing.Color.White
        Me.MyDataGrid1.Size = New System.Drawing.Size(759, 226)
        Me.MyDataGrid1.TabIndex = 2


        '
        'personalportal
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(791, 532)
        Me.Controls.Add(WorkidLabel)
        Me.Controls.Add(Me.WorkidTextBox)
        Me.Controls.Add(Me.MyDataGrid1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MinimumSize = New System.Drawing.Size(791, 566)
        Me.Name = "personalportal"
        Me.Text = "Personal Job Portal"
        CType(Me.TrackingDB1BindingSource, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.EcallDataSet, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.MyDataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents EcallDataSet As ecall.ecallDataSet
    Friend WithEvents TrackingDB1BindingSource As System.Windows.Forms.BindingSource
    Friend WithEvents TrackingDB1TableAdapter As ecall.ecallDataSetTableAdapters.TrackingDB1TableAdapter
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents WorkidTextBox As System.Windows.Forms.TextBox
    Friend WithEvents MyDataGrid1 As MyDataGrid.vb.MyDataGrid

Thank you

:confused::confused:
 
Last edited by a moderator:
Back
Top