[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2003-12-10
7
Medium Priority
?
395 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 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