0

这是我用来设置列样式的代码...但它仅适用于 windows CE5 但是当我在最新的 Mobile Psion Omnii Xt15 上使用它时,宽度将被忽略,并且每列仅显示约 20 像素,都被压扁了。

这是我用来绑定网格的 DataTable..

    /// <summary>
    ///Represents the strongly named DataTable class.
    ///</summary>
    [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")]
    public partial class ContainersDataTable : global::System.Data.DataTable, global::System.Collections.IEnumerable {

        private global::System.Data.DataColumn columnContainer_ID;

        private global::System.Data.DataColumn columnScanValue;

        private global::System.Data.DataColumn columnLkContainerType_ID;

        private global::System.Data.DataColumn columnParentContainer_ID;

        private global::System.Data.DataColumn columnQuantity;

        private global::System.Data.DataColumn columnContainerType_Text;

        private global::System.Data.DataColumn columnScanValueDisplay;

        private global::System.Data.DataColumn columnGenComment;

        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        public ContainersDataTable() {
            this.TableName = "Containers";
            this.BeginInit();
            this.InitClass();
            this.EndInit();
        }

这是我用来设置列样式的代码...

 private void InitializeContainerGrid()
    {
        DataGridTableStyle ts = new DataGridTableStyle {MappingName = "Containers"};

        // container type 
        DataGridColumnStyle unitCol = new DataGridTextBoxColumn
                                          {
                                              MappingName = ContainerType_Text,
                                              HeaderText = "Unit",
                                              Width = 50
                                          };
        ts.GridColumnStyles.Add(unitCol);

        // scan value
        DataGridColumnStyle scanValueCol = new DataGridTextBoxColumn
                                               {
                                                   MappingName = "ScanValueDisplay",
                                                   HeaderText = "Scan Value",
                                                   Width = 110
                                               };
        ts.GridColumnStyles.Add(scanValueCol);

        // number of fruit
        DataGridColumnStyle fruitNoCol = new DataGridTextBoxColumn
                                             {
                                                 MappingName = Quantity,
                                                 HeaderText = "Fruit",
                                                 Width = 50
                                             };
        ts.GridColumnStyles.Add(fruitNoCol);

        containerGrid.TableStyles.Add(ts);
    }
4

1 回答 1

0

结果发现,Psion 的分辨率是其他设备的两倍。所以虽然看起来它没有设置宽度,但实际上是……由于分辨率加倍,它只是我预期的一半。

于 2013-07-18T22:22:37.230 回答