是否可以操作绑定到数据源的DataGridView上的格式? [英] Is it possible to manipulate the format on a DataGridView that is bound to a Data Source?

查看:96
本文介绍了是否可以操作绑定到数据源的DataGridView上的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SQL Server 2005和Visual Studio 2008,C#。



在数据源(SQL Server数据表)我使用日期格式 mm / dd / yyyy ,但是,在表单概述(DataGridView)中,用户希望看到完整的其他格式,包括年,周号和星期几( yyww,d )。
我创建了一个这种转换的算法,但是可以用yyww,d代替mm / dd / yyyy来填充受影响的单元格吗?
在这种情况下 - 我该怎么做?



我想我需要在单元格填充之后,但在显示之前进行。 / p>

通用的问题是 - 如何处理数据源绑定DataGridView单元格的格式。

解决方案

CellFormatting事件可以帮助它...在将数据填充到单元格后触发,您可以根据该事件的要求格式化数据


I´m using SQL Server 2005 and Visual Studio 2008, C#.

In the data source (the SQL Server data table) I use the date format mm/dd/yyyy, however, in a forms overview (DataGridView) users would like to see a completely other format, with year, week number and day number of week (yyww,d). I´ve created an algorithm for this transformation, but can I populate the affected cells with yyww,d instead of mm/dd/yyyy? And in that case - how would I do it?

I guess I need to do it after the cells are populated, but before they are shown.

The generic question is - how do I manipulate the format of Data Source bound DataGridView cells.

解决方案

CellFormatting Event can help it... it is triggered after populating data to cell and u can format that data as per requirement in that event

这篇关于是否可以操作绑定到数据源的DataGridView上的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆