Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# DevExpress xtragrid datetime不显示小时和分钟_C#_Datetime Format_Xtragrid - Fatal编程技术网

C# DevExpress xtragrid datetime不显示小时和分钟

C# DevExpress xtragrid datetime不显示小时和分钟,c#,datetime-format,xtragrid,C#,Datetime Format,Xtragrid,在我的datagrid中,我有一个DateTime字段,它不显示小时和分钟。好吧,至少它显示00:00,但我的DateTime值不能是00:00。我使用这个时间格式字符串“dd-MM-yyy-HH:MM” 当我在弹出窗口中显示DateTime值时,它会显示小时和分钟(以及秒),所以不能是00:00: 如何强制datagrid显示小时和分钟 这是我的代码: namespace DXWindowsApplication1 { public partial class Form1 : Xt

在我的datagrid中,我有一个DateTime字段,它不显示小时和分钟。好吧,至少它显示00:00,但我的DateTime值不能是00:00。我使用这个时间格式字符串“dd-MM-yyy-HH:MM”

当我在弹出窗口中显示DateTime值时,它会显示小时和分钟(以及秒),所以不能是00:00:

如何强制datagrid显示小时和分钟

这是我的代码:

namespace DXWindowsApplication1
{
    public partial class Form1 : XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            InitGrid();

        }
        BindingList<Message> gridDataList = new BindingList<Message>();
        void InitGrid()
        {
            /*gridDataList.Add(new Message("joepie de poepie test \n joep meloen hallo \n mhooooo", "username", new DateTime(2008)));
            gridDataList.Add(new Message("test message 2 \n kitkat android \n toktoktoktotktotktokt", "Pipo", new DateTime(2005)));
            gridDataList.Add(new Message("test message 2 \n kitkat android \n toktoktoktotktotktokt", "Pipo", new DateTime(2006)));
            gridDataList.Add(new Message("test message 2 \n kitkat android \n toktoktoktotktotktokt", "Pipo", new DateTime(2007)));*/
            gridControl1.DataSource = gridDataList;
            gridView1.ExpandAllGroups();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            gridDataList.Add(new Message(memoEdit1.Text, "username", DateTime.Now));
            gridView1.ExpandAllGroups();
            memoEdit1.Text = "";
        }

    }
}

DateTime
值在XtraGrid中自动分组为日期,除非列的
GroupInterval
属性明确设置为
Value

上的DevExpress文档中描述了此行为


旁注:如果您没有对
CustomUnboundColumnData
进行任何处理,请不要设置
UnboundType
属性。您可以使用
RepositoryItemDateEdit
在网格中显示时间,并分配
VistaEditTime=DevExpress.Utils.DefaultBoolean.True

例如


你所展示的是一个小组赛。它在单元格中是如何显示的?您是否在DateEditRepositoryItem或列本身上设置了格式?我已将GroupFormat属性设置为
DateTime“dd-MM-yyy-HH:MM”
,该值来自绑定到datagrid的对象。我对列进行了分组。GroupInterval属性设置为默认值。请显示CustomUnboundColumnData事件处理代码。我没有CustomUnboundColumnData事件。我刚刚发布了我所有的代码。
            // colsendTime
            // 
            this.colsendTime.AppearanceCell.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
            this.colsendTime.AppearanceCell.Options.UseBackColor = true;
            this.colsendTime.Caption = "Verzonden op";
            this.colsendTime.DisplayFormat.FormatString = "dd-MM-yyyy HH:mm";
            this.colsendTime.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.colsendTime.FieldName = "sendTime";
            this.colsendTime.GroupFormat.FormatString = "dd-MM-yyyy HH:mm";
            this.colsendTime.GroupFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.colsendTime.Name = "colsendTime";
            this.colsendTime.OptionsColumn.ReadOnly = true;
            this.colsendTime.UnboundType = DevExpress.Data.UnboundColumnType.DateTime;
            this.colsendTime.Visible = true;
            this.colsendTime.VisibleIndex = 2;
DevExpress.XtraEditors.Repository.RepositoryItemDateEdit oItem = New DevExpress.XtraEditors.Repository.RepositoryItemDateEdit();

oItem.DisplayFormat.FormatString = "dd-MM-yyyy HH:mm"
oItem.EditFormat.FormatString = "dd-MM-yyyy HH:mm"
oItem.VistaEditTime = DevExpress.Utils.DefaultBoolean.True
this.colsendTime.ColumnEdit = oItem
this.colsendTime.AppearanceCell.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.colsendTime.AppearanceCell.Options.UseBackColor = true;
this.colsendTime.Caption = "Verzonden op";
this.colsendTime.Name = "colsendTime";
this.colsendTime.OptionsColumn.ReadOnly = true;
this.colsendTime.UnboundType = DevExpress.Data.UnboundColumnType.DateTime;
this.colsendTime.Visible = true;
this.colsendTime.VisibleIndex = 2;