C# DevExpress网格如何关闭列排序

C# DevExpress网格如何关闭列排序,c#,wpf,devexpress,C#,Wpf,Devexpress,strong文本我向用户显示了网格,不允许对每列进行排序,因为我添加了总计 我在哪里做这个 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blen

strong文本我向用户显示了网格,不允许对每列进行排序,因为我添加了总计 我在哪里做这个

          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
                xmlns:devx="http://schemas.devexpress.com/winfx/2008/xaml/grid">
//* * * * * * * *
•您的帖子没有太多上下文来解释代码部分;请更清楚地解释你的情况

    <Grid x:Name="LayoutRoot" >
        <Border BorderThickness="2" BorderBrush="AliceBlue" Margin="10" >
            <StackPanel  >
                <Grid Background="AliceBlue" Height="30" >
                    <TextBlock VerticalAlignment="Center" FontWeight="Bold" Margin="5" Text="Upload File">
                    </TextBlock>
                </Grid>
                <Grid>
//* * * * * * * *

                    <Grid.RowDefinitions>
                        <RowDefinition ></RowDefinition>
                        <RowDefinition Height="800"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5">
                        <Button Content="Upload File" Margin="0" Width="70" Height="35" Command="{Binding CmdUploadFile}" IsEnabled="{Binding IsEnableUploadFile, Mode=TwoWay}" ></Button>
                        <Button Content="Export" Margin="2,0,0,0" Width="70" x:Name="btnExport" Click="btnExport_Click"></Button>
                    </StackPanel>
//* * * * * * * *

                    <devx:GridControl 
                        Grid.Row="1"  x:Name="dgTest" 
                        ShowLoadingPanel="{Binding Path=IsLoading, Mode=TwoWay}"
                        ItemsSource="{Binding Path=LstData, Mode=TwoWay}" 
                        AutoPopulateColumns="False"
                        HorizontalAlignment="Stretch" 
                        VerticalAlignment="Stretch" 
                        AllowColumnMRUFilterList="False" 
                        IsFilterEnabled="False">
//* * * * * * * *


                        <devx:GridControl.Columns>
                            <devx:GridColumn Header="Fac ID"           FieldName= "FacID"          ReadOnly="True" Width="100" ></devx:GridColumn>
                            <devx:GridColumn Header="Patient ID"       FieldName= "PatID"          ReadOnly="True" Width="100" ></devx:GridColumn>
                            <devx:GridColumn Header="Patient"          FieldName= "Patient"        ReadOnly="True" Width="200" ></devx:GridColumn>
                            <devx:GridColumn Header="Price Cd"         FieldName= "PriceCd"        ReadOnly="True" Width="100" ></devx:GridColumn>
                            <devx:GridColumn Header="Invoice Group"    FieldName= "InvoiceGrp"     ReadOnly="True" Width="100" ></devx:GridColumn>
                                                  </devx:GridControl.Columns>
//* * * * * * * *

                        <devx:GridControl.View>
                            <devx:TableView></devx:TableView>
                        </devx:GridControl.View>
                    </devx:GridControl>
//* * * * * * * *

                       </Grid>
                           </StackPanel>
                                  </Border>
                                               </Grid>

//* * * * * * * *


                        </UserControl>

//* * * * * * * *
//* * * * * * * *
//* * * * * * * *
//* * * * * * * *
//* * * * * * * *
//* * * * * * * *
试试这个

<devx:TableView AllowSorting="False"></devx:TableView>

您应该浏览WPF XtraGrid的部分

要删除对列的排序,可以执行以下操作

  • 将列的GridColumn.SortOrder属性设置为ColumnSortOrder.None

  • 从ColumnView.SortInfo集合中删除引用所需列的项

  • 调用ColumnView.ClearOrting方法。这将删除所有列(分组列除外)的排序设置

    gridView1.Columns[“Country”].SortOrder=DevExpress.Data.ColumnSortOrder.None

要防止对特定列进行数据排序/分组,请使用 财产


参考:

您使用的是什么DevExpress网格?这个XAML只是标准的布局网格。我更新了代码,很抱歉。我在最后添加了这个,但它没有预先排序