简体   繁体   English

自定义Win CE设备的DataGrid

[英]Customize DataGrid for Win CE Device

I'm writing an application for windows ce, so I have to use VS 2008. 我正在为Windows ce编写应用程序,因此必须使用VS 2008。

I'm showing some Data in a dataGrid-Control (DataGridView NOT available!), and I want to customize it. 我在dataGrid-Control中显示一些数据(DataGridView不可用!),我想对其进行自定义。

things like grid.Columns[i].width etc are not working on these controls. 诸如grid.Columns [i] .width等之类的内容不适用于这些控件。

I need to change the columns width and header texts, how can I achieve that? 我需要更改列宽和标题文本,如何实现? The datagrid gets it entries at runtime with this line: datagrid通过以下行在运行时获取它的条目:

dgLatestPositions.DataSource = items;

items is a list<> containing objects, the table got 2 columns. items是一个包含对象的list <>,该表有2列。 The view of the dataGrid is working fine, except these issues. 除了这些问题外,dataGrid的视图工作正常。

edit: Maybe something like that? 编辑:也许像那样吗? (It's not working yet either) (它也不起作用)

DataGridTableStyle t = new DataGridTableStyle();
t.GridColumnStyles[0].HeaderText = "Coding";
t.GridColumnStyles[1].HeaderText = "Amount";
dgLatestPositions.TableStyles.Add(t);

Edit: 编辑:

All Items are contained in a List. 所有项目都包含在列表中。 The article-objects looks this way: public class lastChanges 项目对象的外观如下:公共类lastChanges

{
    public long coding { get; set; }
    public int amount { get; set; }
}

The Table shows up like this (example) 表格显示如下(示例)

coding |amount 编码量

0123456789|3 0123456789 | 3

0829346128|4 0829346128 | 4

What I need to do is resize the first column and change the captions 我需要做的是调整第一列的大小并更改标题

We too have an app that requires back support under WindowsCE and has to be done in VS2008. 我们也有一个需要WindowsCE支持的应用程序,并且必须在VS2008中完成。 You are very close, and what we did was created a base-class data grid for display and added a method to add the columns we wanted getting the heading text, binding column source and then the width. 您非常接近,我们创建了一个用于显示的基本类数据网格,并添加了一种方法来添加想要获取标题文本,绑定列源以及宽度的列。 Here is our method and the "myTblStyle" is your DataGridTableStyle "t" variable. 这是我们的方法,“ myTblStyle”是您的DataGridTableStyle“ t”变量。

public void AddColumn(string hdr, string colName, int colWidth)
{
    DataGridTextBoxColumn tbc = new DataGridTextBoxColumn();
    tbc.HeaderText = hdr;
    tbc.MappingName = colName;
    tbc.Width = colWidth;
    myTblStyle.GridColumnStyles.Add(tbc);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM