DdoubleD 315 Posting Shark
float OverTime::getsalary()
{
	if (hoursWork > 40)
	{
		hourlyRate += (hourlyRate /2);
	}
	else

	return hoursWork * hourlyRate;
}

Problem with the above function is you have an else clause you don't need. In the above, not all paths return a value because the return statement is part of your else clause only, but the function expects you to return a float regardless of the logical paths.

DdoubleD 315 Posting Shark

There are many example projects of file compression in CPP: CPP and File Compression

DdoubleD 315 Posting Shark

It is hard to determine what you require. Can you supply a textual pattern of what the design should look like after it is drawn?

Where do the values of "side" and "border" come from?

DdoubleD 315 Posting Shark

Look at Array.IndexOf and Array.LastIndexOf , which will give you the index of the first and last occurrence of the int in your array.

DdoubleD 315 Posting Shark

Here is a demo with source that might get you started to at least evaluating a packaging app as an option: ZipStorer

DdoubleD 315 Posting Shark
System.Reflection.Assembly exe = System.Reflection.Assembly.GetEntryAssembly();
   
      string exePath = System.IO.Path.GetDirectoryName(exe.Location);

i put SpaServiceBill.rpt in the paranthesis but it does not work

In the code snippet above, the var exePath will contain the path where you executed the application, which is what I think you had asked. Now, if you combine that with your report name (I believe you said that the report file is in the same location), you will have a full path/filename to the report's location:

string rptFile = exePath + "SpaServiceBill.rpt";
DdoubleD 315 Posting Shark

Have you considered embedding a packaging utility in your application that can package and unpackage compressed file(s) that could be distributed with your application?

DdoubleD 315 Posting Shark
int playerNum;
char playerSymbol;

// decide whose turn it is.
if (playerNum == 1)
    playerSymbol = 'X';
else
    playerSymbol = 'Y';

cout<<"\nPlayer " << playerNum << " make your move. Choose locations 1 to 9 \n";
cin>>input;
switch (input)
{
    // same switch code, but don't hard-code 'X' or 'Y'.  Replace 'X' and 'Y' in code with playerSymbol.
}

Modified to show how you can stop using goto statements:

bool ValidateMove (int location, char playerSymbol)
{
	switch (location)
	{
		// same switch code, but don't hard-code 'X' or 'Y'.  Replace 'X' and 'Y' in code with playerSymbol.

		// return false if invalid move and such, or true if valid
	}
}

void TicTacToe (void)
{

	int playerNum;
	char playerSymbol;
	bool done = false;
	int input;

	do
	{
		// decide whose turn it is.
		if (playerNum == 1)
			playerSymbol = 'X';
		else
			playerSymbol = 'Y';

		cout<<"\nPlayer " << playerNum << " make your move. Choose locations 1 to 9 \n";
		cin>>input;

		// TODO: use input to get sentinel to determine to exit

		// if valid, change players...otherwise, just loop and ask location again...
		if (ValidateMove(intput, playerSymbol))
		{
			// setup for next player
			if (1 == playerNum)
				playerNum = 2;
			else
				playerNum = 1;

			continue;
		}

		// TODO: if game is over, set done = true or just break

	} while (!done);
}
DdoubleD 315 Posting Shark

Anytime. Cheers!

DdoubleD 315 Posting Shark

Well, not entirely sure what you mean but everyone uses winrar rar / zip files :\

But if it is not possible then it isn't possible ='[

Not possible? I don't think anyone is saying it isn't possible. You just have to determine what is practical and reliable (and perhaps legal) to achieve your goal. Anyway, I don't know if you have seen this tool: Resource Hacker. I have not looked at it, but I used to modify resources in assemblies some time ago and I believed I used VS to do it, but I can't remember why--LOL. I just didn't want you to leave the discussion thinking it wasn't possible when maybe it is..., but I don't want to fool you into believing it's a practical idea either.

Cheers!

DdoubleD 315 Posting Shark

OK, found something obvious: You have defined "linkedList" name for definition (in .cpp), but "LinkedList" name for declaration (in .h). Fix that and see what you get...

Also, you left off the "bool" keyword in definition of isEmpty in .cpp. Change to: template <class Storeable> bool LinkedList<Storeable>::isEmpty()

DdoubleD 315 Posting Shark

so i should replace "Storeable" with "Type" ? My teacher didn't say much about templates, i was under the impression that you can put whatever word you wanted like a variable. The book im looking at uses "Type" so thats where i got that from.

am i missing something else painfully obvious?

No, disregard my previous, but brief rant--LOL. These types of errors can be so elusive... I haven't seen the "obvious" here either yet.

DdoubleD 315 Posting Shark

What is the definition of Storeable? You declare types, but I don't see the definition.

DdoubleD 315 Posting Shark

You forgot to include the contents of: "nodeType.h"

kyosuke0 commented: very helpful +1
DdoubleD 315 Posting Shark

Hy, I want to create several mdb files. Done that,I've created several tables, populated them, but I want to protect them by a custom password. How can I do that? :icon_confused:
Thanks!

Not sure if this is a C# question, but if you open your MDB and goto Tools > Security > Set database Password, you can put a password protection on it.

NOTE: Password protection on the Access file alone is not enough unless you are just preventing accidental viewing of the database. Search the web on this topic and you will see why...

DdoubleD 315 Posting Shark

Check out this MSDN link and look at the C++ example: String to Array using Split

DdoubleD 315 Posting Shark

Sure.

C2535 - means you already defined a function with that name and parameter list. It's been a while for me in cpp, but try commenting out the prototype statement at line 34 above and see what happens.

C1075 - means you have some misplaced/mismatched braces. Check your opening and closing brace pairs for each block and you will find where your match(es) are missing or misplaced.

DdoubleD 315 Posting Shark

Please use code tags--it is very difficult to look at code that is not formatted.

You posted your code, but you haven't indicated a problem. Is there a particular problem you are noticing (compiling or at runtime)?

You should also attach your input data file so when someone wants to help you they can have everything they need to get started.

Cheers!

DdoubleD 315 Posting Shark

goto? really? Why not put the switch code into a function bool ValidInput(...) and then loop for each user's input until it is valid?

while (!ValidInput(...))
{
    cout<<"...make your move...";
    cin>>input;
}

You could then reuse one set of the switch code for each user input call. Though it is possible to do this with goto statements as well, I won't help you with that--very nasty stuff!:P

DdoubleD 315 Posting Shark
System.Reflection.Assembly exe = System.Reflection.Assembly.GetEntryAssembly();
            string exePath = System.IO.Path.GetDirectoryName(exe.Location);
DdoubleD 315 Posting Shark

Sounds similar to another user's question. See responses and see if it fixes your problem: http://www.daniweb.com/forums/thread220905.html

DdoubleD 315 Posting Shark

You can certainly call the OpenFileDialog in your click event: http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx

Your application can delete the files they have selected if that is what you want, or load them and have your app do something with it. If you want to allow the user to save a resource, you could use the SaveAsDialog: http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx

You can also customize the dialog if you want to limit it's function or something.

DdoubleD 315 Posting Shark

If you can understand what is happening in the example I gave you, then you should be able to achieve your objective as you have described it. I also highly recommend you look at the thread that Scott directed you to, which is a fine display of how you can also "wire" the delegate to events (if I remember it correctly).

DdoubleD 315 Posting Shark

Ok, so this was a bit more simple than I thought... Here's the method I created to display the control's event info

private void LogIt(object sender)
{
checkedList.Items.Add((string)sender.ToString());
}

Then after the click event of every control I simply put LogIt(sender) and it sends the info into the listbox.
My new problem is that the checked list box is on a different form called 'frmEventInfo.' I have a button on the main form that displays frmEventInfo. I want to keep the LogIt method and have all of the events that it has saved sent onto the listbox on frmEventInfo. How can I do that?

Here is an example that you can see how to make your method a delegate passed to another form. Copy this code into a source file's class and just call the YourClassName.TestDelegate() method while stepping through the code and you will see what is happening:

public delegate void Delegate_LogIt(object sender);

        public class MyMainForm
        {
            private void LogIt(object sender)
            {
                // commenting out your code line so this will compile
                //checkedList.Items.Add((string)sender.ToString());
                Console.WriteLine(sender.ToString());
            }
            public void Run()
            {
                RunBogusForm2();
            }

            public void RunBogusForm2()
            {
                // pass in method LogIt to new form as delegate
                MyCalledForm bogusForm = new MyCalledForm(LogIt);
                int justAnObject = 3000;
                bogusForm.RaiseFakeEvent(justAnObject);
            }
        }
        public class MyCalledForm
        {
            public Delegate_LogIt delegate_LogIt;
            public MyCalledForm(Delegate_LogIt delegate_LogIt)
            {
                this.delegate_LogIt = delegate_LogIt;
            }

            // mimicking an event
            public void RaiseFakeEvent(object sender)
            {
                delegate_LogIt(sender); // will call your LogIt(sender) method
            }
        }
        public static void TestDelegate()
        {
            MyMainForm bogusForm = …
DdoubleD 315 Posting Shark

actually iam using .net 2008 is it the same as 2005?

I think there is a link on that page for 2008 version: Deployment with VS 2008

DdoubleD 315 Posting Shark

You probably need to commit your changes. See AcceptChanges() method.

DdoubleD 315 Posting Shark

I still don't understand why your Current property always returns the same instance

public object Current
        {
          get
          {
            try
            {
              return dataSrc;
              //return dataSrc.data1[index]; ???
            }
            catch (IndexOutOfRangeException)
            {
              throw new InvalidOperationException();
            }
          }
        }

To be honest I don't know that I can help you much. I don't understand the entity relationship and they don't have meaningful names and the way things are implemented.... it makes it a little hard to follow the code. :(

It doesn't access it directly because I allowed the properties to handle the index out of range during initialization. I don't know why, but during intialization the binding methods will attempt to access the property accessor after it has moved through the list (builds its own list) but without resetting Reset() and MoveNext() or something. This exception doesn't appear until I turned on all the exception options in the debug Exceptions menu. I'm not sure exactly how MS intended this to be handled when binding to a Data Source Object (wizard function) and I wouldn't have gotten this far had I had seen it was doing this in the beginning. I'm going to start up the bigger application with these extended exceptions turned on (scary man) and see what happens because I haven't done that yet...:scared:

DdoubleD 315 Posting Shark

I'm not sure why Serkan's example was not sufficient, but here is another demonstration. You would need to complete the case labels with the remaining conditional requirements.

public static void Test()
        {
            int [] A = {6090, 6100, 6200};
            bool b = CompareAB(A, 995);
            b = CompareAB(A, 1005);
        }
        public static bool CompareAB(int[] A, int B)
        {
            switch (B)
            {
                case 995:
                case 1005:
                case 1010:
                    if (A.Contains(6090) && (A.Contains(6100) || A.Contains(6110)))
                        return true;
                    break;
                case 1015:
                case 1020:
                case 1030:
                    break;
            }

            return false;
        }
DdoubleD 315 Posting Shark

Thanks for you input Scott.

The Data Source Objects (Data1Source and Data2Source in this case) are wrappers around some existing code in an experiment to implement binding of controls to data objects whos relationships are already being managed. This whole endeavor began as I modified the form interface from a very large form, then to two forms (parent/child), then to a tabcontrol design. It was at this point I thought to myself it would be nice if I could wrap the Data Source Object design around each of the data managers along with the Validating and Validated events and then I could just drag these fields onto forms or whatever in the future and not have to do any additional coding to implement the controls or their types.

You return the data source passed in the constructor regardless of the position of the enumerator AND the enumerator should always encapsulate its own index! You don't want another class having r/w access to it.

The index that would normally be encapsulated in the IEnumerator interface is/was already encapsulated in the classes containing the data objects, which is what this simulated implementation represents. I exposed this index for the purpose of this test. Since the MS example implementation of this interface prescribes only the methods needed by the interface, I don't think it should matter where the index is located as long as the implementation is cooperative to prevent conflict. However, I do agree with you in the ideal sense.

DdoubleD 315 Posting Shark

This article appears to answer your exact problem: Disable Outlook Security Message

DdoubleD 315 Posting Shark

Hi. Did you figure this problem out yet? I could simply give you a short and precise answer to your question--Yes (LOL), but you probably want to know what the reason is too, right?

Can you attach the report file and list what the "3 specific values" are?

DdoubleD 315 Posting Shark

Yes, well, consider the source--FOX News. I was working with a CPA a couple of weeks ago who exclaimed, "I don't want socialized medicine."--she's on Medicare--LOL. She went on to tell me about a Glen Beck show she was watching and how they had all these "experts" there and it seemed very "unbiased" too. Yeah right, Glen Beck and unbiased in the same sentence (LOL).

Glen Beck is out there right now touting how we have the greatest health care system in the world, but when he was with CNN in 2008/01, he did a special on his own experience and was dogging America's health care system bad--opposite bandwagon now that he reports with "FIX" News.

Having said all that, it's still important we be careful about the amount of power we give the president. Just look at all the abuses committed by the previous administration. But, like you said, the Bill isn't done.

DdoubleD 315 Posting Shark

Old fashion alarm clock for me. Pull out mechanism on the back to engage, placed across the room so I have to get out of bed to turn it off, and definitely no snooze. Using a snooze could be a subject for a whole new blog! However, if I had an iPhone, I would definitely use it while traveling if the volume is sufficient; and I suspect it would be sufficient for my light sleep modality.

DdoubleD 315 Posting Shark

Scott, I just wanted to say thanks for taking the time and I hope you feel better soon. I will explain the why's and how's tomorrow as best I can. In the mean time, get some rest and get well my friend.

I came down with one hell of a cough so I haven't been online lately :(

Give me a day or two and i'll take a look at it.

DdoubleD 315 Posting Shark

Ok, I think I see what's going on here and it was easy enough to fix the arg out range for Data1Source object. I don't know whether it's a good way or not:

public string Key
        {
            get {
                // allows init to complete until ResetCurrentItem occurs
                if (data1.index < 0 || data1.index >= data1.Count())
                    return string.Empty;

                return data1.Current().key; 
            }
            set {
                if (data1.index < 0 || data1.index >= data1.Count())
                    System.Diagnostics.Debug.Assert(false); // should never happen because item will already exist before user can edit

                data1.Current().key = value;
            }
        }

Not sure yet how I will handle the Data2Source when the list is empty, or why it works when there is one item in the list. And yes, I am enjoying having this conversation with myself...:|

DdoubleD 315 Posting Shark

Someone outside the forum recommended I enable more options in the IDE's Debug/Exceptions setup, so I checked all of them and ran the progam. I'm not sure why these are all unchecked by default, but I'm getting an exception much sooner now.

When this line of code is executed:

data1SourceBindingSource.DataSource = dataMgr.data1Source;

the form begins going through it's binding to object code enumerates through my list. I've implemented the IEnumerable interface, but the binding code seems to still be executing passed the end of my list. I have 30 items in the list and I would expect it to use the MoveNext() method to realize it has reached the end of the list, but it fails accessing my Key property when the dataSrc.data1.index is already equal to the dataSrc.data1.Count .

Have I not implemented the IEnumerable interface correctly? :

public class Data1Source : IEnumerable
    {
        public Data2Source data2Source;
        public Data1 data1;

        public Data1Source(Data1 data1, Data2 data2)
        {
            this.data1 = data1;
            data2Source = new Data2Source(data2);
        }

        public string Key
        {
            get { return data1.Current().key; }
            set { data1.Current().key = value; }
        }
        public Data2Source Data2Source // allows it to show up in Data Sources tab
        {
            get { return data2Source; }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return new Data1SourceEnum(this);
        }
    }

    public class Data1SourceEnum : IEnumerator
    {
        Data1Source dataSrc;

        // Enumerators are positioned before the first element
        // until the first MoveNext() call.
        // int position = -1;

        public Data1SourceEnum(Data1Source dataSrc)
        {
            this.dataSrc = dataSrc;
            dataSrc.data1.index = -1; …
DdoubleD 315 Posting Shark

I already searched web about this error and I still cannot figure it out why it is happening. I am the only who is updating the database, there are no other users. The DataRequestTable has primary key defined (NodeID). I have UPDATE statement defined for myDBAdapter. I have no clue why is this happening...

Have you ensured you don't have any other processes on your machine (viewer/editor of some sort) holding a lock on the record: application that wasn't killed, etc.

Also, is you app doing anything else that might have selected for update or delete operation.

I know you have been working on it several days, but have you tried a shutdown/restart, then running your app as the very first thing you do to know whether it is happening from your app?

DdoubleD 315 Posting Shark

2. Can any one explain how to make a form modal when the showDialog is called from a timer instead of the parent form thread?

If your thread has access to the parent form's handle, I think you can pass that into the ShowDialog(IWin32Window owner) to get that behavior.

DdoubleD 315 Posting Shark

1. Can any one explain the inner workings of the form.enabled property so that I can have it use a list to traverse through the hierarchy of its own controls it has to enable? I have read that if enabled uses a list, it is faster; but I have no idea how to actually implement this idea.

You can iterate through all of the form's controls when the Form's enabled property is changed in the EnabledChanged event:

private void Form1_EnabledChanged(object sender, EventArgs e)
        {
            bool bEnabled = this.Enabled;
            foreach (Control ctrl in this.Controls)
            {
                ctrl.Enabled = bEnabled;
            }
        }
DdoubleD 315 Posting Shark

I promise it is a compilable project--:P It is really small and to the point.

If anybody who understands how the binding occurs can help with this, I'd really appreciate it.

I am fairly new to C# and very ignorant about how objects are bound to controls.

Thanks!!

DdoubleD 315 Posting Shark

This snippet demonstrates how to obtain several objects from an Outlook folder. I don't use Outlook, so I can't really verify it, but maybe it will help get you started: Outlook Folder Objects

I went ahead and created a method for this code I referred, and there was a syntax error, which is fixed in the snippet I am including here. I began testing, but got as far as the Logon call when it started up the Outlook Install Wizard. So, I stopped because I didn't want to install Outlook. I am passing in a sub folder parameter in the definition, but have commented out the line and gone with the hardcoded folder from the Folders collection because I didn't know a valid sub folder to provide. Anyway, here is the code if you want to try it:

public static void GetOutlookItems(string subFolderName)
        {
            Microsoft.Office.Interop.Outlook.Application app = null;
            Microsoft.Office.Interop.Outlook._NameSpace ns = null;
            Microsoft.Office.Interop.Outlook.PostItem item = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null;

            try
            {
                app = new Microsoft.Office.Interop.Outlook.Application();
                ns = app.GetNamespace("MAPI");

                // The following line will begin the install wizard for Outlook if not installed.
                ns.Logon(null, null, false, false);

                inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
                //subFolder = inboxFolder.Folders[subFolderName]; 
                subFolder = inboxFolder.Folders[1];// also works-- which folder?
                Console.WriteLine("Folder Name: {0}, EntryId: {1}", subFolder.Name, subFolder.EntryID);
                Console.WriteLine("Num Items: {0}", subFolder.Items.Count.ToString());

                for (int i = 1; i <= subFolder.Items.Count; i++)
                {
                    item = (Microsoft.Office.Interop.Outlook.PostItem)subFolder.Items[i];
                    Console.WriteLine("Item: {0}", i.ToString());
                    Console.WriteLine("Subject: {0}", item.Subject);
                    Console.WriteLine("Sent: {0} {1}", item.SentOn.ToLongDateString(), item.SentOn.ToLongTimeString());
                    Console.WriteLine("Categories: {0}", item.Categories);
                    Console.WriteLine("Body: {0}", item.Body);
                    Console.WriteLine("HTMLBody: {0}", …
DdoubleD 315 Posting Shark

I guess the problem is c# creates the textboxes after runs my naming code. If there way to get the names directly from the database? Or another way for doing this?

Just an FYI because it's not a solution to your problem. Unless you have manually implemented the creation of your controls, they are created in the form's constructor via a call to InitializeComponents() . So, assuming that this is how your controls are created, then they have already been created because your form's Load() method gets called after the form is created, but before it shown/active.

Here is an excerpt from MS about the designer generated method:

InitializeComponent is a designer-managed area of your form code to which the designer serializes relevant initialization code for the controls and components hosted on the form. The designer uses InitializeComponent to remember control state across form loads at design time and to initialize controls for run-time execution

DdoubleD 315 Posting Shark

This snippet demonstrates how to obtain several objects from an Outlook folder. I don't use Outlook, so I can't really verify it, but maybe it will help get you started: Outlook Folder Objects

DdoubleD 315 Posting Shark

Sorry, I uploaded the wrong/broken project. It's basically the code posted above, but I'll try zipping up the correct one again later.

Here is the correct project--thanks!

DdoubleD 315 Posting Shark

I would suggest doing a search on that error to determine what could be the cause. I don't think that code should pose a problem if everything else is in sync.

Regards.

DdoubleD 315 Posting Shark

Sorry, I uploaded the wrong/broken project. It's basically the code posted above, but I'll try zipping up the correct one again later.

DdoubleD 315 Posting Shark

Here is what the code looks like. There are no tables, just simple binding to Data Source Object:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataSourceBindingTest
{
    public partial class Form1 : Form
    {
        public DataManager dataMgr;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dataMgr = new DataManager();
            data1SourceBindingSource.DataSource = dataMgr.data1Source;

            for (int i = 0; i < dataMgr.data1.Count; i++)
                comboBox1.Items.Add(dataMgr.data1[i].Key);

            //////////////////////////////////////////////////////////////////////////////////
            // This line of code will stop the Exception.
            // As long as there is at least one Item in the data2.List, no binding error occurs.
            
            dataMgr.data2.Add(new Data2ListItem("Item 4", "someField text"));
            
            //////////////////////////////////////////////////////////////////////////////////

            comboBox1.SelectedIndex = 0;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selIndex = comboBox1.SelectedIndex;
            dataMgr.data1.index = selIndex;
            dataMgr.data2.index = dataMgr.data2.Find(comboBox1.Items[selIndex].ToString());
            data1SourceBindingSource.ResetCurrentItem();
            EnableControls();
        }

        private void EnableControls()
        {
            someFieldTextBox.Enabled = keyTextBox.Enabled = 
                dataMgr.data2.index >= 0 ? true : false;
        }

    }
}

////////////////////// form1.designer.cs
namespace DataSourceBindingTest
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new …
DdoubleD 315 Posting Shark

I also tested with the default CrystalReport generated file that derives from ReportClass (as embedded resource), which also derives from ReportDocument , and my cast allows it to setup each tables connection info, but I didn't change the values for the new ConnectionInfo object because I didn't need to. I'm not sure why yours would crash from doing this. Is it crashing during this setup, or not until executing a Refresh() ?

DdoubleD 315 Posting Shark

I get this error that I don't know how to properly prevent it from happening:

Cannot bind to the property or column SomeField on the DataSource.
Parameter name: dataMember

I'm including a zipped up project I created that simulates what is happening in my much larger application.

I have created two Data Source classes, and embedded Data2Source member object inside of Data1Source class.

I then added Data1Source object to Data Sources tool tab via wizard.

When I run this tabcontrol form, if I click on the Tab2 without having items in my Data2Source's list, I get this error and I don't know how to properly handle this when there are not yet items in its list. If I have at least one item in the Data2Source's List, I have no problem.
"SomeField", from the error message above, is a Property in Data2Source and is bound to a control on Tab2.

The idea is that user could create several Data1Source List items, each of them having 0 - many Data2Source List items. Data2Source List items cannot exist without corresponding item existing in the Data1Source List.

To create a Data2Source List item and see it run without error, uncomment the dataMgr.data2.Add(new Data2ListItem("Item 4", "someField text")); in the Form1_Load event:

private void Form1_Load(object sender, EventArgs e)
        {
            dataMgr = new DataManager();
            data1SourceBindingSource.DataSource = dataMgr.data1Source;

            for (int i = 0; i < dataMgr.data1.Count; i++)
                comboBox1.Items.Add(dataMgr.data1[i].Key);

            //////////////////////////////////////////////////////////////////////////////////
            // This line of code will stop the Exception. …
DdoubleD 315 Posting Shark

there is no ListView.SelectedListViewItemCollection in compact framework 2.0, i am trying to create one.
Any ideas?

Try ListView.SelectedIndices Property , which is supported in the 2.0 compact framework. MSDN Reference