.net-2.0

Bind Multiple Lists to a DataGridView

↘锁芯ラ 提交于 2019-12-23 17:23:14
问题 I have two static lists which are to be bound to a DataGridView along with two button fields. I could only bind one list and a button field. Is it possible to bind more than one list to the DataGridView ? ServiceController objSAVAdminService = new ServiceController("SAVAdminService"); ServiceController objSAVService = new ServiceController("SAVService"); ServiceController objPPVService = new ServiceController("PPVService"); ServiceController objMLLService = new ServiceController("MLLService")

.net Resource DLL with multiple resx files

て烟熏妆下的殇ゞ 提交于 2019-12-23 15:52:34
问题 I need to know the way to properly access strings and images from a resource DLL that has multiple resource files (.resx). I have a very large project that I am working on and is composed of several winforms each with multiple panels. I am trying to tidy things up a bit by making each form has its own res file and limit the application to one resource DLL instead of multiple resource DLLs. The problem is when I try and add a new resource file to my resource DLL and try to access a string, for

Escaping new-line characters with XmlDocument

余生颓废 提交于 2019-12-23 15:43:58
问题 My application generates XML using XmlDocument. Some of the data contains newline and carriage return characters. When text is assigned to an XmlElement like this: e.InnerText = "Hello\nThere"; The resulting XML looks like this: <e>Hello There</e> The receiver of the XML (which I have no control over) treats the new-line as white space and sees the above text as: "Hello There" For the receiver to retain the new-line it requires the encoding to be: <e>Hello There</e> If the data is applied to

Is it possible to use generic constraints based on attributes rather than types? [duplicate]

心不动则不痛 提交于 2019-12-23 15:35:38
问题 This question already has answers here : Can you use “where” to require an attribute in c#? (5 answers) Closed 6 years ago . I'm trying to write a class that will be in charge of persisting application options. Since the options need to be persisted the values that I'm sent must be serialisable. Initially I thought I've be able to write a method with a signature like this: Public Sub SaveOption(Of T As ISerializable)(ByVal id As String, ByVal value As T) or if you prefer C#: public void

DataGridView binding problem: “Index -1 does not have a value.”

╄→尐↘猪︶ㄣ 提交于 2019-12-23 13:13:07
问题 I have a datagridview bound to a binding source and a couple buttons on a form. One button adds an item to the binding source, the other removes the currently selected item. There's also an event handler that listens to the CurrentChanged event and updates the Enabled status of the Remove button. Everything is hunky dory until I go to remove the last item from the datagridview. Then I see a very ugly exception: at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at System.Windows

How to Catch an exception in a using block with .NET 2.0?

回眸只為那壹抹淺笑 提交于 2019-12-23 13:03:12
问题 I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally ... any code samples to point me in the right direction? Edit: The question was modified after reading through the replies. It was "How to Throw an exception in a using block with .NET 2.0?" but I was actually looking for a way to catch these exceptions inside a using block.

Sending a DataTable as a parameter to stored procedure

对着背影说爱祢 提交于 2019-12-23 12:34:36
问题 I'm trying to send a DataTable to a stored procedure using c#, .net 2.0 and SQLServer 2012 Express. This is roughly what I'm doing: //define the DataTable var accountIdTable = new DataTable("[dbo].[TypeAccountIdTable]"); //define the column var dataColumn = new DataColumn {ColumnName = "[ID]", DataType = typeof (Guid)}; //add column to dataTable accountIdTable.Columns.Add(dataColumn); //feed it with the unique contact ids foreach (var uniqueId in uniqueIds) { accountIdTable.Rows.Add(uniqueId)

Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?

女生的网名这么多〃 提交于 2019-12-23 12:32:07
问题 I'm building an Active Directory wrapper in VBNET 2.0 (can't use later .NET) in which I have the following: IUtilisateur IGroupe IUniteOrganisation These interfaces are implemented in internal classes (Friend in VBNET), so that I want to implement a façade in order to instiate each of the interfaces with their internal classes. This will allow the architecture a better flexibility, etc. Now, I want to test these classes (Utilisateur, Groupe, UniteOrganisation) in a different project within

(DataGridView + Binding)How to color line depending of the object binded?

ε祈祈猫儿з 提交于 2019-12-23 12:22:28
问题 I would like to add a backcolor for specific line depending of a Property of the object binded. The solution I have (and it works) is to use the Event DataBindingComplete but I do not think it's the best solution. Here is the event: private void myGrid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { for (int i = 0; i < this.myGrid.Rows.Count; i++) { if((this.myGrid.Rows[i].DataBoundItem as MyObject).Special) { this.myGrid.Rows[i].DefaultCellStyle.BackColor = Color

Button image too far from top of button; too close to bottom of button

旧城冷巷雨未停 提交于 2019-12-23 10:39:38
问题 I'm working on a Windows Form in VB.NET 2005 and I would like to have some buttons with images (I'm talking about the plain, vanilla System.Windows.Forms.Button). I have everything set up the way I want it but the images are displaying too low on the button, such that the bottom of the icon is almost right on the bottom of the button and there is a lot of space above the image. Here is a screenshot: Button Screenshot http://www.freeimagehosting.net/uploads/b28a5c63b8.jpg See how the corner of