WPF Change a DataGrid column from Read/Wright to Read only in back code.-VBForums
Results 1 to 2 of 2

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

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2013
    Posts
    58

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

    Hello , I have a Datagrid set up this way.

    Code:
     <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">
    
                        <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Seq" Width="50*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Name="txtSeq" Text="{Binding SEQ, Mode=OneWay}" MouseDoubleClick="txtSeq_MouseDoubleClick" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
    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
    Location
    Cebu, PH
    Posts
    1,868

    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
    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: My Blog | GitHub Repo | ASP Snippets | CodeASP.net
    ___________________________________________________________________________________

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.