DdoubleD 315 Posting Shark

What is a row header? Aren't the values you are showing as being incorrect really just incorrect cell values in the first column without a column heading?

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

I saw on this calculation on the web, but I don't have a .dss file to test it with...

public static long GetDSSDuration(string fileName)
        {
            FileInfo fi = new FileInfo(fileName);
            long size = fi.Length;

            long length = (long)(((size * 1.1869) - ((size / 1054) * 210)) / 1054);

            if (length > 1000)
            {
                length = (long)(length * (0.61 + ((length / 100) * 0.0005)));
            }
            else
            {
                length = (long)(length * (0.61 + ((length / 100) * 0.0015)));
            }

            return length;
        }
DdoubleD 315 Posting Shark

This download demonstrates how to read/write wave file headers: Wave File Headers...

DdoubleD 315 Posting Shark

Half of the code I have already :) I have miles and miles of code for applications i've done over the years.

Let me know when you publish your stuff man... I want an autographed copy too it that can be arranged! ;)

DdoubleD 315 Posting Shark

Yea, your post was pinged by one of the best.... Now mark as solved and give sknake some +rep for his work.

DdoubleD 315 Posting Shark

Cool... I hadn't seen this class used before! I noticed when I tried to delete a subfolder I got a system error... I have not checked the MSDN doc on this yet so maybe that is a given...

I would like to suggest that unless you are going to use default control names (eg. changeList instead of listBox1) that you go ahead and post the designer portion of the code too.

Good information though! Cheers!

DdoubleD 315 Posting Shark

If you have not already, take a look at this thread, which quite a bit of work went into related to your question: http://www.daniweb.com/forums/thread226540.html

Then, if you have tried implementing this and cannot get it to work the way you want, post the relevant code with question (project too to be sure).

DdoubleD 315 Posting Shark

No consequences for making wrong guesses--kind of like how you posted this thread 3 consecutive times?

DdoubleD 315 Posting Shark

Ryshad, that code looks good to me, but for some reason when I execute it (have only tried with one PictureBox added in the panel) the Remove(pic2remove) method in the picture_click() event doesn't seem to remove the control from the panel. I don't see why this wouldn't work and it relates to a similar post I made where you provided input as well... Any thoughts as to why this is?

My apologies sir... That code works fine. I had my form and panel sized so small I didn't notice it was filling that location with next picture... :$ One of those moments for me I suppose....

DdoubleD 315 Posting Shark

Ryshad, that code looks good to me, but for some reason when I execute it (have only tried with one PictureBox added in the panel) the Remove(pic2remove) method in the picture_click() event doesn't seem to remove the control from the panel. I don't see why this wouldn't work and it relates to a similar post I made where you provided input as well... Any thoughts as to why this is?

Heres some code demonstrating how to name the control at creation and adding an event handler to its Click() event. I have used the click event to delete the control:

namespace WindowsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                PictureBox pb = new PictureBox();
                pb.Image = Properties.Resources.pic1;
                pb.Name = "pic" + i.ToString();
                pb.Click += new EventHandler(picture_click);
                flowLayoutPanel1.Controls.Add(pb);
                
            }
        }

        void picture_click(object sender, EventArgs e)
        {
            PictureBox pic2remove = (PictureBox)sender;
            flowLayoutPanel1.Controls.Remove(pic2remove);
        }
    }
}
DdoubleD 315 Posting Shark

Can explain better what it is you are doing?

DdoubleD 315 Posting Shark

Please mark this thread as solved and create a new thread with question about matching string expressions.

Cheers!

DdoubleD 315 Posting Shark

You are in the wrong forum... There is an ASP.NET forum under the Web Development tab.

DdoubleD 315 Posting Shark

Here is some code to show you what you asked:

// 2nd param false if not searching child controls of control...
            Control[] ctrls = flowLayoutPanel1.Controls.Find("searchkey", false);

            // Note: only one can be selected (made active), so if Find returns more than one,
            // the last one in array will be the selected control using this loop...
            foreach (Control c in ctrls)
                c.Select();

            // if only one control returned (exact match), make it active...
            if (ctrls.Length > 0)
            {
                ctrls[0].Select();

                // to remove this control...
                flowLayoutPanel1.Controls.Remove(ctrls[0]);
            }
DdoubleD 315 Posting Shark

Here you go....

private void DisplayResults()
    {
      textBoxCurrentPage.Text = curPage.ToString();
      int recStart = 0 + (RECORDS_PER_PAGE * (curPage - 1));
      int recEnd = recStart + RECORDS_PER_PAGE;
      listView1.BeginUpdate();
      listView1.Items.Clear();
      if (currentSearchResults != null)
      {
        for (int i1 = recStart; i1 < recEnd; i1++)
        {
          if (currentSearchResults.Length > i1)
          {
            ListViewItem lvi = listView1.Items.Add(currentSearchResults[i1].FormType.Name);
            lvi.SubItems.Add(currentSearchResults[i1].Caption);
            lvi.Tag = currentSearchResults[i1];
          }
          else
            break;
        }
          // reorder matching search item to be at top
          ReorderItemToTop(textBox1.Text);
      }
      listView1.EndUpdate();
      buttonNext.Enabled = (curPage < maxPage);
      buttonPrev.Enabled = (curPage > 1);
    }

    void ReorderItemToTop(string name)
    {
        // sort items so our FindItemWithText finds first closest match index...
        // this will put them in the best order based on ascending...
        // if there is an exact match to name, it will be found first in code below...
        listView1.Sort();

        // Locate item beginning with name's text...
        ListViewItem item = listView1.FindItemWithText(name, true, 0, true);

        // if found and more than one item, begin moving them up the list....
        // If an exact match was found, it will be put at the top...
        if (item != null && listView1.Items.Count > 1)
        {
            // begin moving matching items up...
            int index = 0; // this is the top where we will put the first/best matching item
            do
            {
                // move item up to next top position...
                item.Remove();
                listView1.Items.Insert(index, item);

                // find next item beginning at index + 1 (skip one we just moved)...
                index++;
                item = listView1.FindItemWithText(name, true, index, true);

            } while (item != null); // until no more matches...
        }
    }
DdoubleD 315 Posting Shark

or perhaps this?:

public void MakeItemTopVisible(string name)
            {
                // Locate item beginning with name's text...
                ListViewItem item = listView1.FindItemWithText(name, false, 0, true);
                // make item first (top) item viewable in the list...
                listView1.TopItem = item;
            }
DdoubleD 315 Posting Shark

OK, is this what you want? Still not tested, but you can look at comments and logic to determine if I have understood your request:

void ReorderItemToTop(string name)
            {
                // sort items so our FindItemWithText finds first closest match index...
                // this will put them in the best order based on ascending...
                // if there is an exact match to name, it will be found first in code below...
                listView1.Sort();

                // Locate item beginning with name's text...
                ListViewItem item = listView1.FindItemWithText(name, false, 0, true);
                
                // if found and more than one item, begin moving them up the list....
                // If an exact match was found, it will be put at the top...
                if (item != null && listView1.Items.Count > 1)
                {
                    // begin moving matching items up...
                    int index = 0; // this is the top where we will put the first/best matching item
                    do
                    {
                        // move item up to next top position...
                        item.Remove();
                        listView1.Items.Insert(index, item);

                        // find next item beginning at index + 1 (skip one we just moved)...
                        index++;
                        item = listView1.FindItemWithText(name, false, index, true);
                    
                    } while (item != null); // until no more matches...
                }
            }
DdoubleD 315 Posting Shark

The window has to be active. Look at the documentation for the SendKeys class: SendKeys Class

umm i know...Hence why i asked here what i can do to make it send to a non-active window....

Sorry, wasn't sure whether you just wanted to get SendKeys to work with it so I was showing how to make it active. Don't know another way to do it, but maybe someone else does. Good luck.

DdoubleD 315 Posting Shark

Not sure if this is what you are looking for and I didn't test this, but it should work OK:

void ReorderItemToTop(string name)
            {
                // Locate item beginning with name's text...
                ListViewItem item = listView1.FindItemWithText(name);
                
                // If exact match, move it to the top of the List...
                if (item != null && name == item.Text)
                {
                    item.Remove(); // remove from current location...
                    listView1.Items.Insert(0, item); // insert at top...
                }
            }
DdoubleD 315 Posting Shark

The window has to be active. Look at the documentation for the SendKeys class: SendKeys Class

[DllImport("User32.dll")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        public static void SendKeysToNotePad()
        {
            try
            {
                // Start notepad...
                Process myProcess = Process.Start(@"notepad.exe");

                // Make the window active...
                SetForegroundWindow(myProcess.Handle);

                // Check to see it process is responding...
                if (myProcess.Responding)
                    // Send keys to the ACTIVE application...
                    SendKeys.SendWait("This text being sent to notepad.exe from " + Application.ProductName);
                
                // not responding... shut it down...
                else
                    myProcess.Kill();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
DdoubleD 315 Posting Shark

You need to check that index because maybe there is no student selected or something.

if (students.SelectedItem < 0)
    MessageBox.Show("No student selected...");
else if (students.SelectedItem >= studentList.Count)
    MessageBox.Show("Programmer Error: List out of Sync with ListBox!");

I have dinner plans so I have to leave now... Good luck and look at all of those comments I made for you showing how to check index to make sure it is valid...

DdoubleD 315 Posting Shark

Here is what you had before:

private void deleteStudent_Click_1(object sender, EventArgs e)
        {
            if (!DeleteStudent(students.SelectedIndex))  //check if student is selected from list.
                MessageBox.Show("Error deleting student..."); //throw message box saying that a student isn't selected.
        }
DdoubleD 315 Posting Shark
private void deleteStudent_Click_1(object sender, EventArgs e)
        {
            if (!DeleteStudent(studentsList.SelectedIndex))  //check if student is selected from list.
                MessageBox.Show("Error deleting student..."); //throw message box saying that a student isn't selected.
        }

Why did you change this method? It was more correct the way you had it before. This won't even compile because "studentList" does not have a SelectedIndex property.

DdoubleD 315 Posting Shark

I can assure you that the index out of range, based on the code I saw, was/is not being caused by lack of memory.

EDIT: You know that when you are debugging this you can look at the list Count property and the value of the index where the error is thrown. You will see the index is >= to Count, or is less than 0, all of which indicate an improper index out of range.

DdoubleD 315 Posting Shark

LOL--though losing work is no laughing matter indeed!

DdoubleD 315 Posting Shark

Reverse engineer the problem... I have shown you how to get the information into the form and you have a reference to the student's Scores and an index of the score being edited. Look how the constructor pulled the student's score, then just reverse that process to put the update in there.

If you are going to be a programmer, or claim to have learned these skills, you need to pick up these fundamentals and begin thinking in a logical manner to figure things like this out.

I really don't know what else to do if you cannot figure this out; other than to write you application for you, but I'm not going to do that and I hope that is not what you want.

DdoubleD 315 Posting Shark

I'm glad if you understand--very good. Before you get side-tracked, Here are some more changes I want you to make, then you can disappear for a while (LOL) while you produce the remaining implementation...

public partial class UpdateScoreForm : Form
    {
        // no need to know about the other form...
        //private UpdateStudentForm parentForm; //current form

        // Score list and index to score being edited
        private int index; //index of score
        private List<int> Scores;

        // Pass in Score list and index to score being edited...
        // The reason we don't just pass in the single score, is because simple
        // types are passed in by value and the result would be lost...
        // There are other ways we could have done this, but let's keep it simple for now...
        public UpdateScoreForm(int index, List<int> Scores)//UpdateStudentForm parentForm, int index)  //pull score from previous form.
        {
            //this.parentForm = parentForm;

            // this.Scores is a reference to Scores passed in, so when we update it,
            // the change will appear in the caller's list too...
            this.index = index;
            this.Scores = Scores;

            InitializeComponent();

            //this.CurrentScore.Text = this.parentForm.GetScoreAtIndex(index).ToString();

            // Set textbox (naming conventions!) to correct score value...
            this.CurrentScore.Text = Scores[index].ToString();
        }

Then in calling form:

private void UpdateScoresButton_Click(object sender, EventArgs e)
        {
            // get the index of selected listbox item (score)...
            // Again, use naming conventions for a listbox...
            int index = CurrentScores.SelectedIndex;
            
            // ensure there is a score selected, or there is nothing to update...
            System.Diagnostics.Debug.Assert (index >= 0);
            
            List<int> scores = studentToEdit.GetScores();

            // ensure the …
DdoubleD 315 Posting Shark

I need to get you to a good starting point. Begin by making these changes. Do not remove the comments at this time because I want you to be able to look back and reflect at what we did:

public partial class UpdateStudentForm : Form
    {
        // You don't need to know about the parent form!!!
        //private Form1 parentForm;  //main form
        
        private Student studentToEdit; //student list
        
        // there is no need to carry around this index, which can cause you index out of range too.
        //private int index; //index

        // this form only needs to know about this student to udpate...
        public UpdateStudentForm(Student updateStudent)
        {
            // set this form's student reference to one passed in...
            this.studentToEdit = updateStudent;

            InitializeComponent();

            // OK--setting textbox for name and listbox for scores...
            this.StudentName.Text = this.studentToEdit.Name;
            UpdateScoreDisplay();
        }

And in main Form1,...

private void updateStudent_Click_1(object sender, EventArgs e)
        {
            // Get the index of the currently selected student in the ListBox
            // Remember naming conventions: students s/b something 
            // like: lbxStudents or listBoxStudents or lbStudents etc...
            int index = students.SelectedIndex;
            
            // ensure this index is valid and in range with our list...
            System.Diagnostics.Debug.Assert(index >= 0 && index < studentList.Count);

            // Get a reference to the selected student in the studentList...
            Student updateStudent = studentList[index];

            // Pass in only the student we are updating...
            UpdateStudentForm updateStudentForm = new UpdateStudentForm(updateStudent);

            // Create form and show as modeless! (ShowDialog())
            updateStudentForm.ShowDialog(); //open new form
        }

EDIT: Let me know when you have those changes and can compile …

DdoubleD 315 Posting Shark

I need you to post your zipped up project--current version...

DdoubleD 315 Posting Shark

If you just need to access a student from the List<Student> type (studentList) using the "id" you are passing in (assuming it is a valid index), here is the change:

public Student GetStudent(int id)
        {
            return studentList[id];
        }
DdoubleD 315 Posting Shark

Hi,

I would seriously recommend checking out some of the many tutorials on Regular Expressions. It is a powerful tool to have under your belt.

Heres a function that will check your data and only allow the valid characters you listed. It will return false if there are double digits(if they arent preceeded by a '/'), non-numerics or any '/'s if not followed by 004 or 005.

Hope this helps :)

private bool ValidInput(string input)
        {
            const string regExpr = @"[^\d\s]|(\d*?(?<!\/|\/\d)([0-9]{2})|(\/(?!00(4|5))))";

            System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(input, regExpr);
            if (m.Success)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

I would probably have spent half a day trying to come up with that pattern--LOL. You seem to be quite adept at creating regex patterns Ryshad. He should +rep you if it works!

DdoubleD 315 Posting Shark

the logic on how to do it, evades me. And I think I must check for IsNumbers and then "/004" "/005"

PortData = "1 2 3 4 5 6 7 8 9 0 /004 /005 /234 234 @ %";
            int index = PortData.IndexOf("1","2","3","4","5","6","7",
"8","9","0","/004","/005");
            if (index > -1)
            {

             }
else
{
MessageBox.Show("Data Corrupt);
}

How is this going to see if there is illegal char's?
Sorry, I do not have a clue hoe to do it

Use Regex to search for legal and illegal patterns in your string. Here is a brief description of doing this: Regular Expressions Usage in C#

You might also find this useful: http://www.regular-expressions.info/

DdoubleD 315 Posting Shark

Here is an example:

// example class to represent your item...
        class MyItem
        {
            public string Text { get; set; }

            // so listbox also knows how to display text for your item...
            public override string ToString() 
            {
                return Text;
            }
        }
        // handle double click event...
        // this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            // get selected item...
            object item = listBox1.SelectedItem;

            // view the text from your item. here I depend on override of ToString for your item...
            string s = item.ToString();

            // Here you pass it into your edit form...
            MyEditForm form2 = new MyEditForm(item); // you have to create the edit form...
            // when the form returns, "item" will contain the changes you made...
            form2.ShowDialog();

            // remove previous item...
            int index = listBox1.SelectedIndex;
            listBox1.Items.RemoveAt(index);
            // insert modified item...
            listBox1.Items.Insert(index, item);
        }
DdoubleD 315 Posting Shark

You have to create a global system hook to capture the window's WM_CONTEXTMENU message and override the default context menu across all applications. Take a look at this thread, which is same conversation about modifying the default system context menu for text editing: custom system context menu. Many people will say you can't do it, but I am betting it can be done. It's not a common thing to do and there is no support for doing this. There is no easy answer.

If you decide to pursue this, you will want to include "global system hook" in your searches. Here is a link to some codeproject examples: Global System Hooks. I did not browse these links and it is possible that one of them might mention your exact request, but I doubt it. Anyway, I hope this steers you in the right direction...

Cheers!

DdoubleD 315 Posting Shark

No worries mate--we all get frustrated sometimes. Looks like you are not giving up and making some headway.

Is there a reason you switched to ArrayList to hold your Student list?

Cheers!

DdoubleD 315 Posting Shark

Fun stuff man! I don't know if it is illusion or what, but does the center (pivot point) move as it rotates?

DdoubleD 315 Posting Shark

You didn't post any code, so don't know what you are doing with your grid. Take a look at this post: http://www.daniweb.com/forums/thread210161.html

DdoubleD 315 Posting Shark

Here's the thing I am trying to load an arraylist of objects with each object having several text properties. Now if I try to do this with this modified code below, I can see each element of the arraylist but not the properties belonging to each object P. I have read many books over the past few weeks and rewritten the code a lot, but I just can't make this work.

Any takers please.

if (Parts.Length > 0)
                Title = GetTitle(parentName);
            ArrayList ps = new ArrayList();
            for (int counter = 0; counter < Parts.Length - 2; counter++)
            {
                PersonalPhoto P = new PersonalPhoto();
               // PhotoStuff P = new PhotoStuff();
                P.FileName = Parts[counter];
                P.DateTaken = GetDatePictureTaken(temp);
                P.Title = Title[counter];
                ps.Add(P);
            }

To access the items in your ArrayList ps, you need to cast the item back to type PersonalPhoto:

for (int i=0; i<ps.Count; i++)
{
  PersonalPhoto p = (PersonalPhoto)ps[i];
  // Now you can access the PersonalPhoto item's properties (eg. p.FileName)
  Console.WriteLine(p.FileName);
}

As an alternative, you could use a strong-typed List instead of an ArrayList:

List<PersonalPhoto> ps = new List<PersonalPhoto>();

            for (int counter = 0; counter < Parts.Length - 2; counter++)
            {
                PersonalPhoto P = new PersonalPhoto();
                // PhotoStuff P = new PhotoStuff();
                P.FileName = Parts[counter];
                P.DateTaken = GetDatePictureTaken(temp);
                P.Title = Title[counter];
                ps.Add(P);
            }

            // access each List/array element as PersonalPhoto...
            foreach (PersonalPhoto p in ps)
            {
                Console.WriteLine(p.FileName);
                Console.WriteLine(p.Title);
                // .... etc.
            }
            // or using index like:
            for (int i = 0; i < ps.Count; i++)
            {
                Console.WriteLine(ps[i].FileName); …
valter commented: Very helpful, solved for what was for me a difficult problem +3
DdoubleD 315 Posting Shark

For example... Here I have added a method to my form.cs file called InitializeComponent2(), which I am calling from the IntializeComponent() method in the form.designer.cs file:

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

        private void InitializeComponent()
        {
            InitializeComponent2();
        }

        private void MyInitializeComponent()
        {
        }

        #endregion

        private System.Windows.Forms.DataGridView dataGridView1;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column6;

    }

I have moved the original code from the IntializeComponent() method into this IntializeComponent2() method in my form.cs file:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent2()
        {
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // dataGridView1
            // 
            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column4,
            this.Column5,
            this.Column6});
            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridView1.Location = new System.Drawing.Point(0, 0);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.Size = new System.Drawing.Size(758, 266); …
DdoubleD 315 Posting Shark

Crapiola. I forgot the designer will no longer allow you to use its design editor once you move out that code. Your project will compile and run OK with the code moved into your form.cs file from the designer.cs file, but the designer will give that Show Call Stack() designer error page when you try to view the form in design mode.

Anyway, to prevent the designer from obliterating your code, you could copy the contents of the IntializeComponent() method into your form.cs constructor, then move it back to the form.designer.cs method whenever you want to use the designer to edit the form. I know it's not much help, but at least you can be sure the designer cannot muck up the code as long as it is in the form.cs file.

EDIT: Just to be clear, the designer looks for the InitializeComponent() method to determine the form's design. Obviously, if you were to cut/paste that method into your form.cs file, the designer would still edit that method, but now it would be editing your form.cs file, which doesn't give any advantage. So if you decide to implement a workaround for this bug, you need to put that contents of the InitializeComponent() method somewhere the designer can't touch it, but again, to use the designer to view the form, you would need to put this code back into that InitializeComponent() method wherever it is …

DdoubleD 315 Posting Shark

You mean i can simply copy and paste the code from the designer.cs to the .cs file? Should that be done inside the Form_load or before InitializeComponent()?

Do it inside the constructor, which is where the InitializeComponent() gets called. Do it after the call to IntializeComponent(), as that is where the control is created. If you wanted to, you could move all of the designer code into your form.cs file. Only problem with doing this is that you will get a designer error screen with prompt to view stack should the designer get confused and you try to view the form in design mode. However, moving the column information from the form.designer.cs file to the form.cs file following the InitializeComponent() call in the form's constructor I think would synchronize. Let me give a demo ride on my machine and get back to you...

DdoubleD 315 Posting Shark

Out of curiosity, was this grid dragged from a Data Source?

Also, though maybe not your preference, I believe you could prevent this from reoccurring if you transfer the form.designer.cs code to your form.cs. You can do this in increments as you are modifying the grid. This way, the designer will not muck it up again with whatever that bug is about. Just a thought.

DdoubleD 315 Posting Shark

I was about to close some browser windows and thought I would post some links I found helpful on this topic:

Remoting_Architecture
.NET Remoting Use-Cases and Best Practices
All you need to know about .NET Remoting
.NET Remoting with an easy example

I suppose I should have added C# to the Tags entry, which I did originally but then removed it due to the limitation of six entries, but then wound up with four entries anyway due to limitations of the 20 char length... Anyway, if anyone knows how I can add "C#" to the Tags, let me know--thanks.

EDIT: I should also point out that I put the service interface directly into the SimpleServer.exe. If you prefer to use a class library (DLL) instead for this purpose, this can easily be achieved.

DdoubleD 315 Posting Shark

Assuming that your IP address and port are correct, have you ensured that the server is not blocking remote connections through that IP/port?

Check firewall and configuration settings on the server.

DdoubleD 315 Posting Shark

Please see this and mark as solved if it answers your question: .NET Remoting Examples...

DdoubleD 315 Posting Shark

Quite a few people have been asking how they can get their applications to talk to each other. More specifically, they have been wanting to know how to access information from another running application using .NET Remoting.

Not having done this before, I decided to take up the challenge and create a simple example of this approach. Thus, this code snippet and attached solution. I only posted relevant code in the snippet, but all projects and files can be found in the attached solution.

The SimpleServer form application runs a form having a textbox that I added some default text to, but you can change this value as you are testing the implementation of the Client form applications.

The SimpleClient1 and SimpleClient2 form applications run a form having a multiline textbox and a button to retrieve text from the SimpleServer application.

In both the SimpleServer and SimpleClient1 examples, the application loads the RemoteConfiguration settings from a configuration file. This is probably the best way to go, as it allows these settings to be modified (to change port, etc.) without the need to recompile the applications

The SimpleServer2 example has the RemoteConfiguration settings hardcoded, and demonstrates using TcpClientChannel as well as Activator.GetObject to communicate with the SimpleServer application.

Cheers!

EDIT: Note that I don't have more than one machine, so I could only perform local machine tests. If you try this on two machines, you will need (at a minimum) to adjust the SimpleServer.config …

ddanbe commented: Great! +4
DdoubleD 315 Posting Shark

Sorry, wrong property. Change to:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string key = (string)comboBox1.SelectedItem;
            textBox1.Text = dict[key];
        }
DdoubleD 315 Posting Shark

:D It happens to us all. Please mark the thread as solved then.

DdoubleD 315 Posting Shark

Is this what you are looking for:

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
            {
                // if your item is text, otherwise cast to proper type:
                string text = (string)comboBox1.SelectedItem;
                switch (text)
                {
                    case "disease":
                        textBox1.Text = "malaria";
                        break;
                    case "medication":
                        textBox1.Text = "aspirin";
                        break;
                    case "control":
                        textBox1.Text = "ktrl";
                        break;
                    default:
                        break;

                }
            }

You may wish to consider doing it this way:

Dictionary<string, string> dict = new Dictionary<string,string>();

            public void AddItems()
            {
                dict.Add("desease", "malaria");
                dict.Add("medication", "aspirin");
                dict.Add("control", "ktrl");

                foreach (KeyValuePair<string, string> kv in dict)
                {
                    comboBox1.Items.Add(kv.Key);
                }
            }
            private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                string key = comboBox1.SelectedText;
                textBox1.Text = dict[key]; // get the value of associated key...
            }