?
Solved

vb.net windows forms - datagrid - left tab - hide

Posted on 2003-12-10
7
Medium Priority
?
393 Views
Last Modified: 2008-02-01
in vb.net windows forms

I would like to use the datagrid just for display purpose.( no insertion or modificaiton or deletion).  

I don't want the datagrid to display a left tab ( > and * will be there to indicate the current row and new row ) before my first column.

give me a suggestion to supress this.

regards,
Rameshkanna
0
Comment
Question by:RameshKanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:tinchos
ID: 9913050
If I'm not mistaken you should set the DataGrid's property

RowHeadersVisible to false

DataGrid dg;
// Code

dg.RowHeadersVisible = false;

Hope this helps

Tincho

0
 
LVL 4

Accepted Solution

by:
krznpsk earned 100 total points
ID: 9913102
To eliminate the "Add new record" row that's inserted by default, set the ReadOnly property of the Datagrid to True.

myDataGrid.ReadOnly = True
0
 
LVL 9

Assisted Solution

by:malharone
malharone earned 100 total points
ID: 9914375
or use a list view ... its a great alternative to datagrids when you only want to display the data and disallow editing.
0
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 
LVL 9

Expert Comment

by:malharone
ID: 9914480
sample:

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ListView1 As System.Windows.Forms.ListView
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
    Friend WithEvents mnuDetails As System.Windows.Forms.MenuItem
    Friend WithEvents mnuList As System.Windows.Forms.MenuItem
    Friend WithEvents mnuSmall As System.Windows.Forms.MenuItem
    Friend WithEvents mnuLarge As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.ListView1 = New System.Windows.Forms.ListView
        Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
        Me.mnuDetails = New System.Windows.Forms.MenuItem
        Me.mnuList = New System.Windows.Forms.MenuItem
        Me.mnuSmall = New System.Windows.Forms.MenuItem
        Me.mnuLarge = New System.Windows.Forms.MenuItem
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'ListView1
        '
        Me.ListView1.AllowColumnReorder = True
        Me.ListView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.ListView1.ContextMenu = Me.ContextMenu1
        Me.ListView1.FullRowSelect = True
        Me.ListView1.GridLines = True
        Me.ListView1.HideSelection = False
        Me.ListView1.HoverSelection = True
        Me.ListView1.Location = New System.Drawing.Point(16, 16)
        Me.ListView1.Name = "ListView1"
        Me.ListView1.Size = New System.Drawing.Size(456, 168)
        Me.ListView1.TabIndex = 0
        Me.ListView1.View = System.Windows.Forms.View.Details
        '
        'ContextMenu1
        '
        Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuDetails, Me.mnuList, Me.mnuSmall, Me.mnuLarge})
        '
        'mnuDetails
        '
        Me.mnuDetails.Index = 0
        Me.mnuDetails.Text = "Details"
        '
        'mnuList
        '
        Me.mnuList.Index = 1
        Me.mnuList.Text = "List"
        '
        'mnuSmall
        '
        Me.mnuSmall.Index = 2
        Me.mnuSmall.Text = "Small Icons"
        '
        'mnuLarge
        '
        Me.mnuLarge.Index = 3
        Me.mnuLarge.Text = "Large Icons"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 200)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(392, 72)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Right click on the list view for options ... ; you can color code the back and fo" & _
        "re colors; you can change the view types to ""detail"", ""list"", ""large/small icons" & _
        """; re-order columns; sort columns ... etc"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(496, 310)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.ListView1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As New DataSet("Data")
        Dim dt As New DataTable("Employees")
        dt.Columns.Add("FirstName", "".GetType)
        dt.Columns.Add("LastName", "".GetType)
        dt.Columns.Add("Salary", (1.1).GetType)
        ds.Tables.Add(dt)
        Dim dr As DataRow
        With dt
            dr = dt.NewRow
            dr("FirstName") = "John"
            dr("LastName") = "Johnson"
            dr("Salary") = 20000
            dt.Rows.Add(dr)

            dr = dt.NewRow
            dr("FirstName") = "Mark"
            dr("LastName") = "Markson"
            dr("Salary") = 30000
            dt.Rows.Add(dr)

            dr = dt.NewRow
            dr("FirstName") = "Lacy"
            dr("LastName") = "Braynt"
            dr("Salary") = 40000
            dt.Rows.Add(dr)

            dr = dt.NewRow
            dr("FirstName") = "Kobe"
            dr("LastName") = "Oneill"
            dr("Salary") = 15000
            dt.Rows.Add(dr)

            dr = dt.NewRow
            dr("FirstName") = "Bill"
            dr("LastName") = "Bush"
            dr("Salary") = 60000
            dt.Rows.Add(dr)

            dr = dt.NewRow
            dr("FirstName") = "George"
            dr("LastName") = "Clinton"
            dr("Salary") = 10000
            dt.Rows.Add(dr)
        End With

        With Me.ListView1
            With .Columns
                .Add("First Name", Me.ListView1.Width / 3, HorizontalAlignment.Right)
                .Add("Last Name", Me.ListView1.Width / 3, HorizontalAlignment.Right)
                .Add("Salary", Me.ListView1.Width / 3, HorizontalAlignment.Right)
            End With
        End With

        Dim ili As New ListViewItem
        For Each dr In ds.Tables(0).Rows
            ili = New ListViewItem(New String() {dr(0), dr(1), Format(dr(2), "currency")})
            ili.BackColor = IIf(dr(2) <= 20000, Color.Gray, Color.White)
            ili.ForeColor = IIf(dr(2) >= 40000, Color.Green, Color.Black)
            Me.ListView1.Items.Add(ili)
        Next
        Me.ListView1.SelectedItems.Clear()
    End Sub


    Private Sub mnuDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDetails.Click
        Me.ListView1.View = View.Details
    End Sub

    Private Sub mnuList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuList.Click
        Me.ListView1.View = View.List
    End Sub

    Private Sub mnuSmall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSmall.Click
        MsgBox("you must first attach pictures -- images to list view for this option to be enabled")
        Exit Sub
        Me.ListView1.View = View.SmallIcon
    End Sub

    Private Sub mnuLarge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLarge.Click
        MsgBox("you must first attach pictures -- images to list view for this option to be enabled")
        Exit Sub
        Me.ListView1.View = View.LargeIcon
    End Sub
End Class
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10287555
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: krznpsk {http:#9913102} & malharone {http:#9914480}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0
 

Author Comment

by:RameshKanna
ID: 10288414
.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question