DdoubleD 315 Posting Shark

Under the .NET tab, I don't have anything that begins with "Microsoft Office" listed.
Under the COM tab, there are numerous "Microsoft Office..." options, but none contain "word.dll". Closest I seem to be able to find is "Microsoft Word 12.0 library" under COM.

Try opening a Word document and keep it open, or open another VS session and create a project of type office document...Then, go back in look in the References->Add dialog of your project in question and I think you will see it. If not, you can use the Browse tab and locate the Word.DLL in your Program Files or wherever you have it installed.

You may also want to visit these links:
http://www.c-sharpcorner.com/...SpellCheckCC.aspx
http://www.codeproject.com/KB/office/SpellCheckUsingWord.aspx

EDIT: I know there was a discussion on using a richtextbox with spellchecker in this forum recently, but I can never seem to get the forum search to work for me...

DdoubleD 315 Posting Shark

Wow, thank you very much. Works like a charm!
You almost made it too easy for me ;)

I thought you were asking how you could determine from main form whether the checkboxes on form2 are checked or unchecked, but it looks like you have your answer.

Please mark this thread as solved. EDIT: Looks like you already did... I'm losing my mind me thinks...

DdoubleD 315 Posting Shark

Add a KeyDown event:

private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (Control.ModifierKeys == Keys.Space)
                ;//spacebar was pressed
        }

Sorry, I just realized I compared apples to oranges somewhat.... Try this instead:

private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Space)
                ;//spacebar was pressed
        }

or, you can also do it this way:

private void textBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == ' ')
                ;//spacebar was pressed
        }
DdoubleD 315 Posting Shark

I don't understand. You say you are trying not to delete the files, but you are deleting: System.IO.File.Delete(file); .

When you say the url extension is not visible, what do you mean?

DdoubleD 315 Posting Shark

Good! Please mark as solved.

DdoubleD 315 Posting Shark

Ya well , it can works for all keys, i just want for space key.....

Add a KeyDown event:

private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (Control.ModifierKeys == Keys.Space)
                ;//spacebar was pressed
        }
DdoubleD 315 Posting Shark

I am curious to see how far you have gotten on this. For the "scoreupdate" form, the purpose is to modifiy scores for one student only (selected from the main form). You have passed in the student object whose scores are to be modified: scoreupdate scoreupdateFrm = new scoreupdate(updateStudent) --good. Now, modify the form's events accordingly. Keep in mind:

  • You are not working with the List<student> Students , so this form doesn't need to know about this list, only the student being updated ( updateStudent
  • You are not creating a new student, so you should not be creating a new object of type student
  • You are only modifying the scores, so there is no need to change the updateStudent.name field
  • The scores listbox is loaded using the same/similar techniques that the students listbox were loaded on your main form--just a different List is being used (scores); also how you get the selected item's index from the listbox for the score to edit, delete, etc.

Implement the functionality for this form and remove code that does not belong with this form that you have copied into it from the other form. Once you have implemented these concepts, we can pick up from there where you still need assistance, but you need to put in the effort in order to develop your understanding/skill.

Also, you need to begin using/adhering to some naming conventions; so think about this as you are writing code. The VS IDE also makes …

DdoubleD 315 Posting Shark

Sorry i thought it worked but i see now that i still can't have a autonumber column in my database...? the bulk insert works from the first column onwards and i need to have the autonumber column...Any further suggestions?

Seems to me you could add/insert an autonumber column after the bulk insert completes: How to: Create an Autonumber DataColumn

DdoubleD 315 Posting Shark

You need to watch how you name things. You don't want to declare variables with names that could conflict with other identifiers...

Here is what you need to do in the update button's event handler:

int index = studentList.SelectedIndex; // index of listbox same as Students...
            student updateStudent = Students[index]; // retrieve student to udpate
            scoreupdate scoreupdateFrm = new scoreupdate(updateStudent); // pass student to update form
            scoreupdateFrm.ShowDialog(); // show the form...

Now, once you put that in there, the constructor for the scoreupdate form needs to be changed to take "student" as parameter, instead of "List<student>". Also, instead of holding a reference to Students, you now need to set a reference to "updateStudent" passed into the form's constructor.

So make those changes and let me know when you are done.

Also, at some point I would like to go through with you in renaming your definitions to be more meaningful and specific to what they are because when the names don't represent closely exactly what they are, it easy to get confused...

DdoubleD 315 Posting Shark

I'm new at this DB stuff using C#, but based on what I've seen, you need to do something like:

OleDbConnection vlAccessConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBFileName);

            string cmd_str = "SELECT CurrentPassword FROM AdminPassword WHERE UserName = 'Admin'";

            DataSet ds = new DataSet();

            OleDbDataAdapter da = new OleDbDataAdapter(cmd_str, vlAccessConnection);

            da.Fill(ds);

            // retrieve the CurrentPassword form the DataSet (ds)
DdoubleD 315 Posting Shark

OK. Here is the code to get the selected item's index:

int index = studentList.SelectedIndex;

Now that you know the index, you need to get a reference to the specific student in the Students list. Do you know how to do that?

You showed how to get the first student as Students[0], but now we want declare a variable that references the specific student...

DdoubleD 315 Posting Shark

We are working with the GUI (form) interface right now, and not the Students list yet. Do you know how to retrieve the selected item from the studentList textbox on your main form: maintain_student_scores ?

DdoubleD 315 Posting Shark

Let's start at the beginning...

On your main form, you have your listbox loaded with the students (name and scores). Since you load this listbox from your list in the same order as your Students list, all you need to do is know the index of the selected item in the listbox to access that student in your list.

Do you know how to get the selected index from the selected item in the listbox?

DdoubleD 315 Posting Shark

Every programmer develops there own preferences, and if you become a programmer on a team, you will want to follow any patterns already in use by the team, or company, which might dictate one way over another.

In this case, lets pass in a student to the form, so you can see that technique...

So first, do you know the index of the student you need to update?

DdoubleD 315 Posting Shark

You could do this either way: List with index; or, pass in the student

How would like to do it?

DdoubleD 315 Posting Shark

What you have shown should work fine. I only suggested adding the name assignment in the OK button event because there is no need to add the name every time the user adds another score for that student--bad coding practice. So, I still suggest waiting until user presses OK to add name:

private void okBtn_Click(object sender, EventArgs e)
        {
            testscores.name = nameTbox.Text;
            Students.Add(testscores);
            this.Close();
        }
DdoubleD 315 Posting Shark

1) Yes on the Clear() method...
2) I wouldn't add this student to the Students list until they press the OK button; what if they press Cancel?
3) You really don't need to add the student's name to anything until they press the OK button: testscores.name = nameTbox.Text . You need to do that before you add testscores to your Students list though...

DdoubleD 315 Posting Shark
Students.Add(testscores);

Now, Students list passed in from the main form will have the new student added and available to any form you pass in the Student list.

DdoubleD 315 Posting Shark

Just loop through all of your scores and append them to a string.

// build a string of all scores separated with space char
            string text = "";
            for (int i = 0; i < testscores.Scores.Count; i++)
                text += " " + testscores.Scores[i];

Now all you have to do is set your textbox: scoresTBox.Text = text

DdoubleD 315 Posting Shark

Ok, up and running and you already solved getting the score added.

What is the next question you have?

DdoubleD 315 Posting Shark

EvilLinux, thanks for including the doc. Since I will probably be spending some time helping you get through this and to understand how it works and pieces together, would you mind just zipping up the entire project for me?

DdoubleD 315 Posting Shark

Sure. Here is the information I need:
1) Explanation of what the newstudent form is supposed to do; I know you are using multi-forms for this project, so specifically what the "newstudent" form's purpose is...
2) post the code from the newstudent.designer.cs file

DdoubleD 315 Posting Shark

Hi

I am new to C# and software development. I have a question. If I were to edit this project:
http://xmlnotepad.codeplex.com/SourceControl/ListDownloadableCommits.aspx

I think I need to:
Download Eclipse with C# plugin
Download source code of the project
Create a new C# project in Eclipse
Copy source code into Eclipse

Did I miss anything? Do I need to have something else installed on my PC in order to run the project within Eclipse?

Thanks a lot.

Tom

The steps you have defined sound about right. You will probably need to tell the Eclipse project what references to include, and there might be some project/solution settings to apply/reapply also. You can view the VS project file using notepad/text editor to see these settings applied for VS.

I haven't used Eclipse, and it sounds like maybe you haven't either. Since nobody else has prescribed any tips for you, I am guessing nobody else in here is using Eclipse either.

If you run into problems getting the XMLNotepad project/solution (whatever the project settings file is called in Eclipse) to build, I would suggest looking for a Forum that deals specifically with the Eclipse IDE. There might be a converter to do this too--I have not checked.

Cheers!

DdoubleD 315 Posting Shark

I've seen your other thread and also that Ryshad has pointed out the ToString override. You can stop posting changes to this thread now and we will focus on the new one--OK?

DdoubleD 315 Posting Shark

You have not defined "title" for Quote and Photo, so how do you want to handle the scenario when the specific class is not RegularPost?

DdoubleD 315 Posting Shark

That is fine! I get it completely but then how would I access the child members outside the IF statement? While using Intellisense outside the loop, on the item variable, I cannot access the child functions.

My actual question is, how do I access child-specific functions outside the IF statement?

When you call the base class virtual function item.GetPostType() , it will invoke the overridden method from your specific class.

EDIT: Now you have me saying "function"--LOL. C# has methods, not functions... try to use the word "method" instead.

DdoubleD 315 Posting Shark

I have tried using your method but then it does not allow me to access the child-class specific properties after returning the list.

I don't know what you mean by "after returning the list". Here is an example of how you need to access the derived Post class (specific child-class) members, and then you can access the common base class members at the end as you were already doing. Nevermind that I stripped out all of the code not needed for demonstrating this concept.

string type = "regular"; // using to demonstrate given functionality
            
            // Declare object reference to access common base stuff from Post
            // Declaring outside of specific Post derived classes below so we
            // can access the common base information later...
            Post item;

            if (type == "regular")
            {
                RegularPost regPost = new RegularPost();
                item = regPost; // allow item object to access the base class members...

                // you can set title from RegularPost object because it is defined there,...
                regPost.title = "some text";

                // but NOT from the abstract class because that is not where it is defined
                //item.title = "some text"; // this will throw a compile error
            }
            else if (type == "quote")
            {
                Quote quote = new Quote();
                item = quote; // allow item object to access the base class members...

                // these are NOT members of Post, so you cannot set them using Post object
                //item.source = (string)postType.ElementAt(1); // compile error
                //item.text = (string)postType.ElementAt(0);// compile error

                // these are members of Quote, …
DdoubleD 315 Posting Shark

Let us all know what you decide so that others might benefit from your experience. Any new information you provide might also lead to possible answers/responses.

DdoubleD 315 Posting Shark
{
            // loading a ListView control with the data...
            foreach (student s in Students)
                listView1.Items.Add(new ListViewItem(s.ToString()/*or s.Name* works too*/));
        }

I get what that is doing, but where are you calling the listView1.Items.Add function from?

Not sure what you mean, because it was being called from the form's Load event until you removed it to ask this question. What are you asking about exactly?

Here is that section of code again:

public partial class Form2 : Form
    {
        List<student> Students;
 
        public Form2(List<student> Students)
        {
            InitializeComponent();
 
            this.Students = Students;
        }
 
        private void Form2_Load(object sender, EventArgs e)
        {
            // loading a ListView control with the data...
            foreach (student s in Students)
                listView1.Items.Add(new ListViewItem(s.ToString()/*or s.Name* works too*/));
        }
    }
DdoubleD 315 Posting Shark

Your welcome and happy coding! Please mark thread as SOLVED if your questions have been answered.

If you run into a problem somewhere, just create a new thread with that problem.

Cheers!

DdoubleD 315 Posting Shark

Ah gotcha, and one last real quick one before I dive into the insanity of my programming ways lol, when your saying class myOtherForm : Form the myOtherForm = the name of the other form(s) I want to be able to access that class.cs and Form = the class name (I.E. student).

I'm sorry if I sound dumb with this, I just like to make sure my details are clearly put before I dive into it head first and then cause a bunch of issue and look even stupider, thanks.

Exactly! Here is an example....

// STUDENT CLASS
    public class student
    {
        // storage/getter/setter property...
        public string Name { get; set; }

        public List<int> Scores = new List<int>();
        

        /* ...
         * your other code here I left out for brevity...
         * ...
         * */

        // average all test scores for class/school or whatever is in our list...
        public static int averageAllStudents(List<student> Students)
        {
            int totScores = 0; // operand is total of all scores for all students
            int totCount = 0;  // dividend is total count of all score entries for all students

            // for every student
            foreach (student s in Students)
            {
                // and for every student score
                foreach (int score in s.Scores)
                {
                    totScores += score; // add score
                    totCount++; // increment count
                }
            }
            return totScores / totCount; // return average
        }

        // completely optional...,but to demonstrate how to override ToString to return name
        public override string ToString()
        {
            return this.Name;
        }
    }

Then, …

ddanbe commented: Who said I was tenacious?? Great! :) +14
DdoubleD 315 Posting Shark

Ok make sense, 3 of my forms require me to pull the data from the student array (I.E. show current scores) and the allow the ability to add\delete them. I guess I'm confused that if I put the array in the main form that the other forms won't be able to access it? Again I might just be thinking too far down the road.

No, now would be the time to think about that, but that problem is solved when you pass the list into the form as I demonstrated using class MyOtherForm : Form as an example.

DdoubleD 315 Posting Shark

Even if you want to average all students' scores, you could put this functionality in the student class. For example public static int averageAllStudents(List<student> Students) :

class student
        {
            private string name;
            public string Name // getter/setter property...
            {
                get { return name; }
                set { name = value; }
            }
            private List<int> Scores = new List<int>();

            // your other code here I left out for brevity...

            // average all test scores for class/school or whatever is in our list...
            public static int averageAllStudents(List<student> Students)
            {
                int totScores = 0; // operand is total of all scores for all students
                int totCount = 0;  // dividend is total count of all score entries for all students

                // for every student
                foreach (student s in Students)
                {
                    // and for every student score
                    foreach (int score in s.Scores)
                    {
                        totScores += score; // add score
                        totCount++; // increment count
                    }
                }
                return totScores / totCount; // return average
            }

            // completely optional...,but to demonstrate how to override ToString to return name
            public override string ToString()
            {
                return this.name;
            }

        }
DdoubleD 315 Posting Shark
// your main form
        class MainForm : Form
        {
            List<student> Students = new List<student>();
 
            // Call one of my other forms....
            public void LoadNextForm()
            {
                MyOtherForm form2 = new MyOtherForm(Students); // pass the list to the form...
            }
        }
 
        // shows how your form can use an existing Students list....
        class MyOtherForm : Form
        {
            List<student> Students; // maintain a reference to same list for each form...
            ListView listView1 = new ListView();
 
            // pass the list into your constructor...
            public MyOtherForm(List<student> students)
            {
                this.Students = students; // set this form's reference to the list...
            }
 
            public void LoadListView()
            {
                foreach (student s in Students)
                {
                    // populate/add using ToString override...
                    listView1.Items.Add(s.ToString());
 
                    // or, using Property for student name...
                    //listView1.Items.Add(s.Name);
                }
            }
        }

Just to be sure I'm doing this correctly, I would create 2 other class files that inhert. the functionality of my main.cs? or do I code everything into my student.cs?
Thank you.

Well, just to be sure, you plan to create a separate class file for each form I imagine, using the designer too, right?

As far as main.cs is concerned, I would eliminate that altogether and put the declaration/instantiation of Students list in the whatever your main Form is.

Since you are storing all scores for a student with that student List entry, there is no need to have an additional wrapper class to hold additional details about an individual student.

DdoubleD 315 Posting Shark

I guess yeah, but I think later in my project because I have to with 5 different forms, and allow selection of students and all their scores\data is stored under the array per their name it would be more functional to make the method Array. Because I have to enter the students -> be able to add\update\delete scores per student.

I'll play around with it a bit, because I'm sure I'm going to confuse myself some more later on.

Nope, don't use Array because you just wind up boxing/unboxing the data. Stick to your strongly typed List<student> and just pass that into each form:

class student
        {
            private string name;
            public string Name // getter/setter property...
            {
                get { return name; }
                set { name = value; }
            }
            private List<int> Scores = new List<int>();

            // your other code here I left out for brevity...

            // completely optional...,but to demonstrate how to override ToString to return name
            public override string ToString()
            {
                return this.name;
            }
        }

        // your main form
        class MainForm : Form
        {
            List<student> Students = new List<student>();

            // Call one of my other forms....
            public void LoadNextForm()
            {
                MyOtherForm form2 = new MyOtherForm(Students); // pass the list to the form...
            }
        }

        // shows how your form can use an existing Students list....
        class MyOtherForm : Form
        {
            List<student> Students; // maintain a reference to same list for each form...
            ListView listView1 = new ListView();

            // pass the list into your constructor...
            public MyOtherForm(List<student> students)
            { …
DdoubleD 315 Posting Shark

See I might have it wrong, but I was figuring that the Array allStudents() would put the list of students in my list box? Again I might be wrong, so correct me if I am.

Not necessarily wrong. I was just curious. You could load the list box using the existing Students list.

DdoubleD 315 Posting Shark

What is the return value of public Array allStudents() to be used for? I'm trying to figure out why you decided on Array as the return type.

DdoubleD 315 Posting Shark

Incidentally, I ran across many blogs indicating you shouldn't create extensions using managed code. I was reading up on the subject somewhat before you indicated you had it solved. I was wondering whether you have considered these concerns and you are confident you won't have the issues they discuss?

DdoubleD 315 Posting Shark

Many of us don't have 64 bit systems, so I'm not surprised you didn't get input. Anyway, just wanted to say thanks for posting your solution because many just say they solved it themselves and that's it.

Cheers!

DdoubleD 315 Posting Shark

Tried your version Ryshad but I get an index out of range error when dataGridView1 RowsAdded event fires.

Set a breakpoint and the RowCount = 1 & RowIndex = 0

Any ideas

Tino

Sorry about reading right over the "Cell" color designator with this thread. Anyway, check your Cell's indexer because the RowIndex looks good...

DdoubleD 315 Posting Shark

There is no need to create a new style as I demonstrated in that example. You can just set the default style:

DataGridViewRow row = new DataGridViewRow();
            row.DefaultCellStyle.ForeColor = Color.Green;
            dataGridView1.Rows.Add(row);

Also, the event handler that Ryshad gave is a more versatile approach and you could set the entire row's ForeColor too instead of individual cells if that is your intention.

DdoubleD 315 Posting Shark

Modify your new rode with new style:

DataGridViewRow row = new DataGridViewRow();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            style.ForeColor = Color.Green; // the color change
            row.DefaultCellStyle = style;
            dataGridView1.Rows.Add(row);
DdoubleD 315 Posting Shark

Modify your new rode with new style:

DataGridViewRow row = new DataGridViewRow();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            style.ForeColor = Color.Green; // the color change
            row.DefaultCellStyle = style;
            dataGridView1.Rows.Add(row);
DdoubleD 315 Posting Shark

You have declared item Post item; to be abstract class reference, which does not contain an object called "title". Set your derived class specific objects like:

if (type == "regular")
            {
                RegularPost regularPost = new RegularPost(); // specific stuff
                item = regularPost; // reference to common stuff...

                regularPost.title = (string)postType.ElementAt(0);
                regularPost.body = (string)postType.ElementAt(1);

Then, "item" can still set the abstract objects that are common. Repeat this for the other derived objects.

DdoubleD 315 Posting Shark

MSDN:
The programmer has no control over when the destructor is called because this is determined by the garbage collector. The garbage collector checks for objects that are no longer being used by the application. If it considers an object eligible for destruction, it calls the destructor (if any) and reclaims the memory used to store the object. Destructors are also called when the program exits.

Take a look at these:
Destructors
Dispose

DdoubleD 315 Posting Shark

Its that line which has the child class specific field. The one with item.title and all the others with child specific fields.

OK, so item.title in this code segment?:

if (type == "regular")
                {
                        item = new RegularPost();
 
                        item.title = (string)postType.ElementAt(0);
                        item.body = (string)postType.ElementAt(1);
                }

What is the definition of: Tumblarity.Post , which I assume is the object being returned by method RegularPost() ?

And, if you really want fast results, zip up your project and attach it so I can build it and reproduce the error quickly...

DdoubleD 315 Posting Shark

What line number of the original code gave you that error you said in the beginning?

DdoubleD 315 Posting Shark

There are so many examples of this inside this forum, many including entire zipped up projects. Begin by taking a look at some of these and if you have problems, just let us know...

DdoubleD 315 Posting Shark

This is not a client/server application.And yes i expect to invalidate the license if they installed on another machine.
I dont know what is appx expiration....
Well this is the first time i am making the setup. i m not very much familiar with it.......
It is not very much clear to me ...........:sad:

Before you begin this solution to validate the license is still in effect, I would suggest it beneficial to determine exactly what your requirements are. In order to prevent an installation on more than X machines, you would need to perform some sort of online authentication. Is that your intention?

In the past, when install disks were shipped on floppies, vendors used to rewrite information to one of the install disks to control the number of allowed installs. As you can imagine, this sometimes led to some issues requiring support staff to intervene or ship new disks when a client needed to reinstall or they wanted to move the application to a different machine. Regardless, you cannot implement this behavior if the media is not rewritable and copy protected.

DdoubleD 315 Posting Shark

I figured out my problem. I had included the database file in the project. Therefore it was overwritten each time I compiled the project, making it look like the database wasn't being updated. I created an external database and it works flawlessly now.
Thanks for the responses.

hi how did you do it?=) cause I'm using microsoft access to store the data and i was wondering how can i make the the database to be updated?

If including the Access database with the project, there is a property you can set for this in the project that prevents compiles from overwriting your updated database. Just select the .mdb in the project (Solution Explorer), and change the Copy to Output Directory property to be "Copy if newer" option.