Results 1 to 2 of 2
  1. #1

    Thread Starter
    Join Date
    Jan 2013

    WPF Change a DataGrid column from Read/Wright to Read only in back code.

    Hello , I have a Datagrid set up this way.

     <DataGrid x:Name="dgTop" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Height="48" RowHeaderWidth="0" AutoGenerateColumns="False" CanUserAddRows="True" CanUserResizeColumns="False" CanUserDeleteRows="False" ScrollViewer.CanContentScroll="True" VerticalScrollBarVisibility="Hidden">
                    <DataGridTemplateColumn Header="Seq" Width="50*">
                                <TextBox Name="txtSeq" Text="{Binding SEQ, Mode=OneWay}" MouseDoubleClick="txtSeq_MouseDoubleClick" />
    I wish to set column “Seq” to Read only using visual basic.
    Something like this.
    dgTop.Columns(0).Isreadonly = True
    Could someone please show me what im doing wrong ?

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Cebu, PH

    Re: WPF Change a DataGrid column from Read/Wright to Read only in back code.

    I use DataGridTextColumn instead of TemplateColumn since DataGridTextColumn inherits DataGridColumn class.

    DataGridTextColumn Class

    XAML Code:
    1. <DataGridTextColumn Header="Name" Binding="{Binding SEQ, Mode=OneWay}" Width="50" />

    VB.NET Code:
    1. dgTop.Columns(0).IsReadOnly = True
    Last edited by KGComputers; Apr 29th, 2016 at 11:12 AM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width