Friday, December 19, 2014

C# combobox duplicate items AutoCompleteSource ListItems

I've found a small problem if you want to use a bind dropdown combobox, that has AutoCompleteMode - Suggest and AutoCompleteSource ListItems: if you have two or more duplicate display members(even with the Value Member different), upon select, lets say, the second duplicate item, the combobox automatically selects the first duplicate item.

To resolve this isue:
Set the comboboxes Causes Validation to False

Thursday, October 2, 2014

Team Foundation Server could not connect to the database after changing the computer

1. Go to IIS - Team Foundation Server - tfs
2. Select Content View
3. Right click web.config, then Browse
4. Edit web.config, look for the old computer name and replace it with the new one
5. Restart IIS
6. Open TFS Administration Console - Application Tier
7. Change URLs

Tuesday, July 23, 2013

Dummy data in Crystal Report at runtime

When using Crystal Reports, in Design mode, you preview your report by clicking "Main Report Preview".

To bind the report I use:
crDaily1.SetDataSource((DataTable)dtDaily);
crDaily1.SetParameterValue("pPeriod", title);

If I put this code in
private void FormReportDaily_Shown(object sender, EventArgs e)
sometimes the dummy data that appears in "Main Report Preview" is shown at runtime. I really don't know the reason?!.

Resolution:

Put the binding code
crDaily1.SetDataSource((DataTable)dtDaily);
crDaily1.SetParameterValue("pPeriod", title);

in the constructor:
public FormReportDaily()

Thursday, October 4, 2012

Expando Object

The ExpandoObject class enables you to add and delete members of its instances at run time and also to set and get values of these members.

Creating a dynamic instance:
       dynamic Student = new ExpandoObject();
       Student.ID = 1;
       Student.Name = "John";
Student.Grade = 10;


Creating a nested dynamic instance:
       Student.Addess = new ExpandoObject();
       Student.Addess.City = "London";
       Student.Addess.Country = "UK";
       Student.Addess.StreetNo = 123456;
Dynamically binding an Event
Student.Click += new EventHandler(SampleHandler);
 
private void SampleHandler(object sender, EventArgs e)
{
//throw new NotImplementedException();
}
Pass parameter as dynamic.
public void Write(dynamic Student)
{
//do stuff
}

Tuesday, July 10, 2012

Dynamicly add xsi:schemaLocation="location" to XML

// Comment
//create XML
XmlDocument doc = new XmlDocument();

//header
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(decl);

//
doc.Schemas.Add("test:schema:v1", "http://sample.com/schema.xsd");
XmlElement decElem = doc.CreateElement("root");
XmlAttribute attr = doc.CreateAttribute("xsi", "schemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
attr.Value = "test:schema:v1 schema.xsd";
decElem .Attributes.Append(attr);
decElem .SetAttribute("xmlns", "decElem");
doc.AppendChild(docElem);

Friday, March 30, 2012

Can't connect to TFS 2010

I've tried:
  1. Stop Collection / Start Collection
  2. Detach / Attach Collection
  3. IIS Stop, Strat , Reset
  4. Flush DNS
  5. Reinstalled TFS
and nothing worked.

I've checked the port 8080 in windows firewall, and was allowed through the firewall but the rule was set to PUBLIC and the network is PRIVATE. Added "private" to the rule and everything works again.

Friday, March 23, 2012

Error when changing an applications Target Framework from 2.0 to 4.0

I've had a problem with Crystal Reports when changing an applications Target Framework from 2.0 to 4.0 

Error:
Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.

Resolution:
Add the following to app.config:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime Version="v4.0" sku=".NETFramework, Version=v4.0" />
startup>
 
 
System: VS 2010, Crystal Reports 13, Windows 7 x64