解决VS2005在Winform窗体设计界面中数据源窗口灰化不显示数据源的问题


近日发现一个问题,在项目中添加了几个数据源,当在Code界面时,数据源窗口可以显示出我添加的数据源,但是一切换到窗体设计界面,数据源窗口就灰化,数据源窗口中所有的数据源都消失了,切换到Code界面,数据源有出来了,切换到设计界面,又消失了,百思不得其解,一定是VS出问题了……

最后经过一顿搜索,原因可能出在“WinFormControls.xml ”文件上,这个文件在

<DriveLetter>:\Documents and Settings\<UserName>\Application Data\Microsoft\Visual Studio\8.0\DataBindingSetting\WinFormControls.xml

首先关闭VS2005,然后查看这个文件中的内容,看看System.Windows.Forms 的版本号是不是2.0.0.0,如果不是,就改成2.0.0.0

如果是2.0.0.0,那么只能删除这个文件。

按如上操作之后,就可以解决这个问题了。

When I am looking at a code window all of my data sources are visible in the data sources toolbox. When I am looking at a form, the toolbox is empty and greyed out and no options can be accessed. This is exactly opposite from how it worked in beta 1, 2 and RC1.

Anyone know what the deal is with this? As of right now I cannot drag/drop a table onto a form because all the tables are hidden when I am looking at a form.
The problem is that for some reason in the dialogue where you can select which controls go with each data type, there were multiple versions of some controls listed. For example for the String datatype, there were two textbox controls listed and selected, for the [LIST] data type, there were two GridView controls selected. One of the controls in each case is version 2.0.0.0, and the other is version 2.0.2600.0. However on one developer machine, there were not any duplicates, but this solution worked for that machine as well.

The solution:

1) Go into tools->options and then select Windows Forms Designer -> Data UI Customization.

2) Select each datatype that is in the drop down list, and deselect all controls. Do this for each and every datatype. This should bring the datasources back into view when you are looking at a form designer window.

3) To be able to again drag and drop the table or field onto a form, you will need to go back into the Ui Customization dialog and select the correct form controls to associate with each datatype, and it is also a good idea to set a default for each. When I deselected all checked items, and clicked ok, and then went back in, the invalid duplicate controls were no longer listed in the dialog, so you cannot accidentally re-select the wrong controls.
Here's a possible explanation for this issue. I will verify it.
- When you change Data UI Customization, the settings are saved under C:\Documents and Settings\<UserName>\Application Data\Microsoft\VisualStudio\8.0\DataBindingSetting\WinFormControls.xml. The full assembly name, including the version is saved.
- Between Beta and RC, the version number was changed.
- MSI engine does not know about this file so it remains there between updates.
- Data Sources tool window loads the settings file, cannot find the controls with the old version numbers and fails.

我通过安装VS2005 SP1解决了这个问题。

http://forums.microsoft.com/msdn/showpost.aspx?postid=125310&siteid=1
(http://www.cnblogs.com/ricky81317/archive/2006/12/29/606798.html)
(http://forums.microsoft.com/msdn/showpost.aspx?postid=125310&siteid=1)
(http://forums.microsoft.com/msdn/showpost.aspx?postid=89678&siteid=1)
(https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=123477)


posted @ 2007-10-03 10:15  emanlee  阅读(1543)  评论(0编辑  收藏  举报