DdoubleD 315 Posting Shark

I don't know how this compiler compares, but I've heard about it and you can check it out if you desire: Mono C# compiler...

DdoubleD 315 Posting Shark

I have no problem with the following snippet with a breakpoint on the return statement...

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                return; // breakpoint here always halts process for me...
        }

If you are still having trouble, zip up your project and attach it.

DdoubleD 315 Posting Shark

If the form's AcceptButton property is set to other than "none", then the form will intercept the <RETURN> key and transfer control to the specified event... Check that the Form's property is not set: (eg. this.AcceptButton = this.button1; )--be sure to look in the form's designer.cs file...

DdoubleD 315 Posting Shark

Setting the form's property this.MaximizeBox = false; prevents the form from being maximized as far as I can tell. Are you saying this is not so in your case?

Setting the form's property this.FormBorderStyle to one of the fixed border styles will prevent it from being sizeable (eg. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; . See FormBorderStyle...

As far as moving the form when maximized, you should not be able to do this, which also relates to your question: "Any ideas to why this works this way?" Maximized form fills the screen, though I don't know how this relates to virtual screens...

DdoubleD 315 Posting Shark

... I'm sure it parses the rows one by one so you could manually read the rows and convert the columns as you import the data instead of using datable.load(); .

...On the client end you have to instantiate the container class and load the buffer.

Thanks for the follow-up sknake. I'm going to mark this as solved, but was wondering if you could refer any examples related to the excerpted quotes above?

DdoubleD 315 Posting Shark

Not sure what you are looking for. Are you wanting to load a table from your database containing the names and their availability (all of info already in table) and then randomly select two names from the table data having records marked/flagged as available?

DdoubleD 315 Posting Shark

Are you wanting a WHERE clause example? If so, what database are you using?

DdoubleD 315 Posting Shark

Just depends on how you want to handle it. If transferring information to caller as node's text, you can do a search of all nodes to find it:

TreeNode FindTreeNodeText(TreeNodeCollection nodes, string findText)
            {
                TreeNode foundNode = null;
                for (int i = 0; i < nodes.Count && foundNode == null; i++)
                {
                    if (nodes[i].Text == findText)
                    {
                        foundNode = nodes[i];
                        break;
                    }
                    if (nodes[i].Nodes.Count > 0)
                        foundNode = FindTreeNodeText(nodes[i].Nodes, findText);
                }
                return foundNode;
            }

If returning the selected node to the caller, you can select it directly:

void SelectNode(TreeNode node)
            {
                treeView1.SelectedNode = node;
            }

and, to know which node is selected to return to caller:

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
            {
                TreeNode node = treeView1.SelectedNode;
            }
DdoubleD 315 Posting Shark

If I have understood correctly, you are wanting to perform a paragraph split when it exceeds the page length? I don't have a direct answer for you and these pdf libraries/utilities generally have a learning curve associated with their lack of documentation, etc. However, you might want to consider alternatives to PdfSharp, depending on what you are doing. If you haven't checked out iTextSharp yet, you might want too. With the following code snippet, I produced an 8 page pdf (horizontal layout) as a result of a long paragraph. There are also header and footer options.

Code snippet:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using PdfSharp.Pdf;
//using PdfSharp.Drawing;
//using PdfSharp.Drawing.Layout;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;

namespace ForumSolutions
{
    public class AcrobatReaderStuff
    {
        public static void Test_iTextSharp()
        {
            Document myDocument;

            myDocument = new Document(PageSize.A4.Rotate());

            PdfWriter.GetInstance(myDocument, new FileStream("c:\\Test_iTextSharp.pdf", FileMode.Create));

            myDocument.Open();

            string tmp = "";
            for (int i = 0; i < 1000; i++)
                tmp += " Here is some more text (" + i + ")... ";

            myDocument.Add(new Paragraph(tmp));

            myDocument.Close();
        }
    }
}

And, here is the Document class definition:

public class Document : IDocListener, IElementListener
    {
        protected int chapternumber;
        protected bool close;
        public static bool Compress;
        protected HeaderFooter footer;
        protected HeaderFooter header;
        protected string htmlStyleClass;
        protected string javaScript_onLoad;
        protected string javaScript_onUnLoad;
        protected float marginBottom;
        protected float marginLeft;
        protected bool marginMirroring;
        protected bool marginMirroringTopBottom;
        protected float marginRight;
        protected float marginTop;
        protected bool open;
        protected int pageN;
        protected Rectangle pageSize;
        public static float WmfFontCorrection;

        public Document();
        public …
TobbeK commented: Very kind, clear and helpful in his comments +2
DdoubleD 315 Posting Shark

Thanks Scott, that works fine for what I'm doing.

Out of curiosity, do you know of a way or example of overriding the default behavior of the datatable's load from the db reader? I was thinking if I had a large table schema with several column types that cannot be directly translated to system types that I would want to consider a more efficient way of performing a load and conversion all-in-one.

DdoubleD 315 Posting Shark

Hello friends! I have some database tables that store Image/Bitmap as part of each record as a Byte[]. I also have method that loads all the tables records into a DataTable and I would like some suggestions on how I can get this Byte[] column in my DataTable to be of type
System.Drawing.Image after or during the load from the DbDataReader .

Thanks in advance!

public DataTable SelectAll(string tableName, DbConnection conn)
        {
            DataTable dt = new DataTable();

            try
            {
                string query = "SELECT * FROM " + tableName;

                conn.Open();

                using (DbCommand cmd = GetDbCommand(query, conn))
                {
                    using (DbDataReader dr = cmd.ExecuteReader())
                    {
                        dt.Load(dr);
                    }
                }
            }
            catch (DbException ex)
            {
                Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
                System.Diagnostics.Debugger.Break();
            }
            finally
            {
                conn.Close();
            }

            return dt;
        }
DdoubleD 315 Posting Shark

I don't have a LDAP server to play with. Here is an example of how to populate the child nodes using DirectoryEntry component that might help you:

TreeNode users = new TreeNode("Users");
            TreeNode groups = new TreeNode("Groups");
            TreeNode services = new TreeNode("Services");
            treeView1.Nodes.AddRange(new TreeNode[] { users, groups, services });

            directoryEntry1.Path = @"WinNT://WORKGROUP/"+ Environment.MachineName;

            foreach (System.DirectoryServices.DirectoryEntry child
               in directoryEntry1.Children)
            {
                TreeNode newNode = new TreeNode(child.Name);
                switch (child.SchemaClassName)
                {
                    case "User":
                        users.Nodes.Add(newNode);
                        break;
                    case "Group":
                        groups.Nodes.Add(newNode);
                        break;
                    case "Service":
                        services.Nodes.Add(newNode);
                        break;
                }
                AddPathAndProperties(newNode, child);

            }

        private void AddPathAndProperties(TreeNode node, DirectoryEntry entry)
        {
            node.Nodes.Add(new TreeNode("Path: " + entry.Path));
            TreeNode propertyNode = new TreeNode("Properties");
            node.Nodes.Add(propertyNode);
            foreach (string propertyName in entry.Properties.PropertyNames)
            {
                string oneNode = propertyName + ": " +
                   entry.Properties[propertyName][0].ToString();
                propertyNode.Nodes.Add(new TreeNode(oneNode));
            }
        }
DdoubleD 315 Posting Shark

This is a little confusing to me... What happened to venkates.99, who started the thread? I see vksingh.24 saying the problem is solved--are the two of you working as a team or something?

If there is still a problem, let us know what it is because there is no uploaded spreadsheet to test with. The data sample-text provided does not cause any problem for me when put into a new sheet with no other values present in the sheet.

Otherwise, if the problem is solved, please update the thread to SOLVED. Thanks.

EDIT: I missed the last post by Ryshad--didn't notice page 2. Anyway, I guess we are all waiting to hear back from vksingh.24.

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

...I went into SQL Server Management Studio Express and granted all privileges to the root user but still no luck.

I think you might be mixing apples and oranges because you indicate you checked your permissions with "SQL Server Management Studio", but you are programmatically trying to create a database using MySql class objects.

Go to the MySql.org and find the sourceforge link to the free MySQL Administrator download and try using that utiltiy to view and modify your source permissions.

DdoubleD 315 Posting Shark

If not required to use Array or ArrayList, I wouldn't use either. Use a typed list instead: List<> .

I would put the method outside of your Team class, but it really depends on where you intend to store your Team list or array.

The best way to return an array or list of objects depends on how you intend to use the returned object.

DdoubleD 315 Posting Shark

Ok, I figured out that the error was actually triggered further down the code. It seems none of my parameters are being added into the query. I'm going to post the rest in case anyone can see what is wrong with it...

OdbcCommand myCommand = myConnection.getCommand("INSERT INTO entries(text, name, screen_name, user_id, posi_score)values(@txt, @nm, @scrNm, @uid, @posi_score)");
                myCommand.Parameters.AddWithValue("@txt", txt);
                myCommand.Parameters.AddWithValue("@nm", nm);
                myCommand.Parameters.AddWithValue("@scrNm", scrNm);
                myCommand.Parameters.AddWithValue("@uid", uid);
                myCommand.Parameters.AddWithValue("@posi_score", posiScore);
                myConnection.openConnection();
                try
                {
                    myConnection.executeNonQuery(myCommand);
                }
                catch (Exception e)
                {
                    Console.Write("Insert failed on entries "+e.Message);
                }

Is there another way to pass these parameters in for an Odbc connection? I worked fine with a straight SQL server connection...

As I understand it, ODBC parameters are positional, not named. So, you would need to have something like this, making sure your parameters are added in the same order as they appear in your SQL statement:

OdbcCommand myCommand = 
                    new OdbcCommand("INSERT INTO entries(text, name, screen_name, user_id, posi_score)values(?,?,?,?,?)");
                myCommand.Parameters.AddWithValue("txt", txt);
                myCommand.Parameters.AddWithValue("nm", nm);
                myCommand.Parameters.AddWithValue("scrNm", scrNm);
                myCommand.Parameters.AddWithValue("uid", uid);
                myCommand.Parameters.AddWithValue("posi_score", posiScore);

EDIT: You may want to consider using a different library to connect to MySQL. I am using MySql.Data.dll, which you can find that and others available free on the internet.

DdoubleD 315 Posting Shark

Thanks for the suggestions, and I did try them. Neither worked, so I looked a little more on the inet and decided to try using the "?" delimiter in place of the "@" symbol--that fixed the problem.

DdoubleD 315 Posting Shark

Here is an example that uses a DataGrid, but it should give you a basis for starting or asking a more specific question: C# DataGrid with DataSet

Cheers!

DdoubleD 315 Posting Shark

A few days ago I decided to install MySql v1.2.17 and I downloaded a client class library: MySql.Data.dll v5.0.9.0 (by MySQL AB). I included the client classes inside my wrapper class and had it creating, dropping, inserting, and deleting tables..., or so I thought. I guess I never actually looked at the records it was creating from my test class.

Here is the problem: All my row data is always NULL values and I cannot figure out why this is! I broke out the wrapper code and placed base class calls into a simple set of statements as represented here:

public static void MySqlTestInsert()
        {
            string connStr = TestDbWrapper.BuildConnectionString(DbWrapperType.MySql);

            string insertCmd = "INSERT INTO TestDbWrapper " +
                "(FieldInt32, FieldVarchar_50, FieldBoolean, FieldDateTime) Values " +
                "(@FieldInt32, @FieldVarchar_50, @FieldBoolean, @FieldDateTime)";
            using (MySqlConnection conn = (MySqlConnection)DbWrapper.GetDbConnection(DbWrapperType.MySql, connStr))
            {
                try
                {
                    conn.Open();

                    using (MySqlCommand cmd = new MySqlCommand(insertCmd, conn))
                    {
                        cmd.Parameters.Add(new MySqlParameter("@FieldInt32", 10));
                        cmd.Parameters.Add(new MySqlParameter("@FieldVarchar_50", "some text..."));
                        cmd.Parameters.Add(new MySqlParameter("@FieldBoolean", true));
                        cmd.Parameters.Add(new MySqlParameter("@FieldDateTime", DateTime.Now));

                        cmd.ExecuteNonQuery();
                    }
                }
                catch (DbException ex)
                {
                    Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
                }
                finally
                {
                    conn.Close();
                }
            }
        }

I don't get any errors, just NULL values in my columns. I have full schema privileges for the database and am able drop, create, and select just fine--though all the values are NULL because that is how they are being inserted.

Any ideas?

DdoubleD 315 Posting Shark

You can also add the event handler directly in your form's constructor in the form of:

public Form1()
        {
            InitializeComponent();
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
         }
DdoubleD 315 Posting Shark

You can handle the close event on the form using the following event handler:

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("Exit without saving changes?", "Data Not Saved", MessageBoxButtons.YesNo))
                e.Cancel = true;
        }

The above event will be called whenever the Close() method is executed. Use e.Cancel = true to stop the form from being closed.

DdoubleD 315 Posting Shark

Have never tried doing that, but here are some interesting links I found while reading up on the subject:

Notification Services...

Send SMS from a Trigger...

xp_cmdshell...

DdoubleD 315 Posting Shark

You need to provide more information about the data retrieval you need. For starters, you should indicate:

1) type of DB (eg. Sql Server, MySQL, Access, etc.)
2) how you expect the data to be loaded into your program (entire table, single field, range of records, etc.)

If you already have some code where you are trying to achieve this, but need some assistance to get it working, include that code too (be sure to use CODE tags).

DdoubleD 315 Posting Shark

You could store all the numeric semantics in a dictionary and then recursively call a translator method (as needed) that whittles it down from most significant to least signicant digits... For example:

Dictionary<uint, string> lookupWord = new Dictionary<uint, string>();

        public void Init()
        {
            lookupWord.Add(0, "siro");
            lookupWord.Add(1, "uno");
            lookupWord.Add(2, "dos");
            lookupWord.Add(3, "tres");
            lookupWord.Add(4, "kwatro");
   ...

            lookupWord.Add(800, "otsosyentos");
            lookupWord.Add(900, "nobesyentos");
            lookupWord.Add(1000, "un mil");
            lookupWord.Add(1000000, "un milyon");
            lookupWord.Add(1000000000, "un bilyon");
        }

        private string ConvertNumToText(uint n)
        {
            if (
                  (n < 20) ||
                  (n < 100 && (n % 10 == 0)) ||
                  (n < 1000 && n % 100 == 0) ||
                  (n == 1000) ||
                  (n == 1000000) ||
                  (n == 1000000000)
               )
            {
                return lookupWord[n];
            }
            else if (n < 100)
            {
                uint tens = n / 10;
                uint ones = n % 10;

                if (tens != 2)
                    return lookupWord[10 * tens] + "-i-" + lookupWord[ones];
                else
                    return lookupWord[10 * tens] + "-" + lookupWord[ones];
            }
    ...

            else if (n < 2000000000)
                return "un bilyon " + ConvertNumToText(n - 1000000000);
            else
            {
                uint billions = n / 1000000000;

                if (n % 1000000000 != 0)
                    return ConvertNumToText(billions) + " bilyon " + ConvertNumToText(n - 1000000000 * billions);
                else
                    return ConvertNumToText(billions) + " bilyon";
            }
        }

The above sample demonstrates working with the Cebuano language, but you can easily see the logic in making the proper interpretation to form a grammatical representation of a number.

DdoubleD 315 Posting Shark

avirag, I don't know how to get the control to display exactly how you want. The view set to detail gives you the single column list (what you have now), but I don't know how to cause it to draw left instead of center.

The largeicon view will give you the left justification, but it begins another column as needed to fill with items. The limit on the image width is 256 (you have 230 now I think), so you can't go much higher. I was able to get the single column to the left (your desired view) by resizing the form and control to be just under the width * 2 requirement it needed to display two columns in largeicon view mode, but for this to look nice and achieve the desired result, you would need to rearrange the items you have in top panel in order to still have them visible after shortening the width of the form to shrink your listview panel...

Maybe someone else has an idea...

DdoubleD 315 Posting Shark

I see the "Hyperlink base" property now... When you started the thread and I played around with the word interop code for some time, I also noticed the "author" property was the same whether modified in word or via explorer shell, so I decided to research an alternative and found dsofile... Anyway, when I looked for the "hyperlink" property last night, I only used the shell to display properties.

Bottom line is that I'm not sure how to get to that hyperlink, but I'll try to spend some more time on this later. In the meantime, go ahead and provide a list of any additional properties you are concerned with.

Also, have you gotten the interop code to create the word file from your existing templates OK? And, if you set those properties at the time you create the doc, does the doc retain the property settings you made?

DdoubleD 315 Posting Shark

ahmm okay..
but about the groupox...
my leader gave us the screenshot of our project that's why i am keep on mentioning that the english equivalent word of the other word that the user entered in the textbox will be displayed in the groupbox..the english word will be obtained in the database that was created...is it not possible?

Possible?--don't know what the screenshot looks like, but probably anything possible.... Can you attach the screenshot so we can see what you are talking about?

DdoubleD 315 Posting Shark

how can we solve the problem of 32/64 bit platform and if they if have different cpu as X86 or x64,

As I understand it, unless you target specifically for the x64 processor, you really don't need to worry about whether your app will be running on x86 or x64 machine. As always though, pay attention to any x64 details when referring to any documentation...

DdoubleD 315 Posting Shark

Are you sure you mean GroupBox? Other than serving to group other controls (encompass, contain), and especially RadioButtons as ddanbe pointed out, I don't know how you would use a GroupBox the way you describe. Changing the GroupBox.Text is easy though: groupBox1.Text = "My GroupBox Text..."; As far as the database retrieval, more info is needed to direct you on how to do that, like: type of database (Access, Sql Server, SQLite, etc...); method of retrieval (SELECT *... or scaler query with WHERE condition, etc...). The basics steps for querying DB are:

1) Establish connection
2) Create a command
3) Execute command

but, there are specific classes for interfacing that functionality depending on the DB and type of query. You will find many examples of such data retrieval inside this forum.

DdoubleD 315 Posting Shark

Hi glado24! Got here as fast as I could...

Now, did you need the complete application with documention and help files attached or just the MySQL database-wrapper interface library?--just kidding--:D

If you search the forum, you should find many examples of what you are asking for, and even some threads related specifically to MySQL. Put together some code using these and other examples from the web and then post more specific question/need based on any problem your having.

There is great DB coding help in this forum when you post a more specific question. ;)

Cheers!

Antenka commented: lol :D +1
DdoubleD 315 Posting Shark

thank a lot DdoubleD for your interest in my problem, i tested the code by your suggested library and he worked fine, and i also tried to solve my original code but it didn't work again :(
But, i have two issues regarding the new library,
the first one that, the Hyperlink base property not supported and
the other that, the library didn't create new files,
so i want to ask if you have a solving to these two issues,
thanks a lot in advance

When I view file properties, I don't see a Hyperlink property... What/where is this?

You can create a word .doc file simply by creating a file with that extension because word has extensive parsing to determine how to read the document, though when you save it from the word application it may no longer be easily recognizable as when you first saved it. I don't know what you are doing as far as "create new files", but I would think that if you were already doing that successfully, you could easily modify the properties afterward using the dsofile api?

DdoubleD 315 Posting Shark

The jpg I looked at seems like it would be more suited for a DataGridView with a DataTable as its DataSource. Why have you chosen to use a ListView?

DdoubleD 315 Posting Shark

Hi Guys I was wondering if anyone could assist me by telling me / correcting my code as to where I am going wrong.

I'm trying to simply excute flvmeta.exe, and pass the parameters:

"flvmeta input.flv output.flv"

when I do this manually it works fine, however when I build and try and run this .exe it does not run the: "flvmeta input.flv output.flv" I know that it is finding the flvmeta.exe, however for some reason there is an issue with my startInfo.Arguments. Could someone please help me out, I'm loosing my hair.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        LaunchCommandLineApp();
    }

    /// <summary>
    /// Launch the legacy application with some options set.
    /// </summary>
    static void LaunchCommandLineApp()
    {
        // For the example
        const string inputFLV = "input.flv";
        const string outputFLV = "output.flv";

        // Use ProcessStartInfo class
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.CreateNoWindow = false;
        startInfo.UseShellExecute = false;
        startInfo.FileName = "flvmeta.exe";
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.Arguments = "flvmeta " + inputFLV + " " + outputFLV + "";

        try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process exeProcess = Process.Start(startInfo))
            {
                Console.Write(startInfo.Arguments);
                exeProcess.WaitForExit();
            }
        }
        catch
        {
            // Log error.
        }
    }
}

You don't need to pass in the name of your exe into the ProcessStartInfo.Arguments property. Try initializing the ProcessStartInfo with the exe: ProcessStartInfo startInfo = new ProcessStartInfo("flvmeta.exe"); Also see: Process.Start & ProcessStartInfo.Arguments...

DdoubleD 315 Posting Shark

Sounds like you have it the way you want--great! Please mark as solved if you have your solution.

Cheers!

DdoubleD 315 Posting Shark

DdoubleD -- Are you sure about removing the event handler?

private void button1_Click(object sender, EventArgs e)
    {
      comboBox1.SelectedIndexChanged = null;
    }

That code won't compile for me. In my Delphi days that is exactly how you cleared event handlers and I like that design but I have never figured out a way you could do it in .NET.

You are right, that won't work! I had somewhere you could this, but had never tried to do it--obviously. I agree it would be nice. Good catch sknake!

DdoubleD 315 Posting Shark

If there are no more questions about this issue, please mark as solved--thanks.

DdoubleD 315 Posting Shark

You cannot directly call a trigger from C#. What you might be able to do is:

1) Separate your trigger code into a stored procedure that can be called by the trigger, and also by the application (c#).

2) Do something from the application that would cause the DB to fire the trigger. This way is kind of kludgee way to do it.

sknake commented: thats how I would do it +6
DdoubleD 315 Posting Shark

I am removing the orignal event handler before adding a new event handler so there shouldn;t be multiple handlers for each instance.

else if (ControlType == "DropDown")
                    {
                        ...
                        field_dropbox.SelectedIndexChanged -= new EventHandler(field_dropbox_SelectedIndexChanged);
                        field_dropbox.SelectedIndexChanged += new EventHandler(field_dropbox_SelectedIndexChanged);
                        ...

In the above, I don't understand why you are removing the event handler and then adding the same event handler right back...


If you want to stop the handler from processing when you are programmatically changing the item that causes the event to fire again, you can set a variable that indicates you are doing just that:

bool bInSelectedChangedEvent = false;

protected void field_dropbox_SelectedIndexChanged(Object sender, EventArgs e)
        {
            if (!bInSelectedChangedEvent)
            {
                // set flag to true to prevent processing while we are changing the item that causes the event to fire again...
                bInSelectedChangedEvent = true;

                // all the processing code in here...
            }
            bInSelectedChangedEvent = false;
         }

However, you might have a design problem if you are modifying another control that is tied to the same event handler, which could then modify another control that is tied to the same event handler, which could then modify another control that is tied to the same event handler, which could then....etc. etc. etc.

Is there a way to purge the eventhandler after it is fired so it does not fire if I make a subsequent change?

Not sure what you mean by purge, but if you can't use the recommendation above and you want to remove all event handlers associated …

DdoubleD 315 Posting Shark

Here is one fix:

bool bInSetUI = false;
        private void SetUI()
        {
            bInSetUI = true; // suspend CheckChanged event

            checkBox1.Checked = AppSet.acon;
            checkBox2.Checked = AppSet.addnew;
            textBox1.Text = AppSet.defNPC;
            checkBox3.Checked = AppSet.shoscr;
            checkBox4.Checked = AppSet.copscr;
            checkBox5.Checked = AppSet.savscr;
            textBox2.Text = AppSet.defpath;
            log.wtl("Interfejs zaktualizowany");

            bInSetUI = false; // resume CheckChanged event...
        }

        private void UpdateSettings(object sender, EventArgs e)
        {
            if (!bInSetUI)
            {
                AppSet.acon = checkBox1.Checked;
                AppSet.addnew = checkBox2.Checked;
                AppSet.defNPC = textBox1.Text;
                AppSet.shoscr = checkBox3.Checked;
                AppSet.copscr = checkBox4.Checked;
                AppSet.savscr = checkBox5.Checked;
                AppSet.defpath = textBox2.Text;
                log.wtl("Ustawienia zaktualizowane");
            }
        }
sknake commented: That was going to be my suggestion until you stole my thoughts :X +6
DdoubleD 315 Posting Shark

Yea, I just stepped through the loading of the form, and you are changing the appsettings to be the current checkbox states every time a checkbox state is changed, so the first assignment in SetUI():

private void SetUI()
        {
            checkBox1.Checked = AppSet.acon;
            checkBox2.Checked = AppSet.addnew;
            textBox1.Text = AppSet.defNPC;
            checkBox3.Checked = AppSet.shoscr;
            checkBox4.Checked = AppSet.copscr;
            checkBox5.Checked = AppSet.savscr;
            textBox2.Text = AppSet.defpath;
            log.wtl("Interfejs zaktualizowany");
        }

causes all the appsetting states to be changed to the current checkbox's states because each checkbox is tied to the CheckChanged event, which is call the UpdateSettings method....

DdoubleD 315 Posting Shark

OK, I've attached my project. Sorry the program is in Polish, but here's what the button labels mean:
Zapisz Ustawienia - Save Settings
Domyślne Ustawienia - Default Settings

Thanks

OK, I downloaded and have gone back to read the thread. You said the Default button (AKA defaultsettings), is something different than what I see. Is this the default settings button you keep having to click: "Załaduj domyślne"?

DdoubleD 315 Posting Shark

...
I make a conscious effort to do it the right way around these days, but commenting always falls to the wayside : / God help anyone who tries to fix/update my code after i leave!

Yea, it's usually people like me who come in after you leave and comment the hello out of it while trying to figure out what it does. :confused: The prevalent attitude I've encountered is: Job Security, ha, ha; but, management doesn't have a clue about what kind of learning curve you are leaving behind to others anyway--ha, ha--:D Anyway, it's usually someone like me that is able to come in and decipher the code and get all kinds of compliments, so it's not all bad. ;)

avirag, let me know if that problem with the duplicate keys is solved with those three lines I added...

DdoubleD 315 Posting Shark

Try this:

// TO USE:
            // 1) include COM reference to Microsoft Excel Object library
            // add namespace...
            // 2) using Excel = Microsoft.Office.Interop.Excel;
            private static void Excel_FromDataTable(DataTable dt)
            {
                // Create an Excel object and add workbook...
                Excel.ApplicationClass excel = new Excel.ApplicationClass();
                Excel.Workbook workbook = excel.Application.Workbooks.Add(true); // true for object template???

                // Add column headings...
                int iCol = 0;
                foreach (DataColumn c in dt.Columns)
                {
                    iCol++;
                    excel.Cells[1, iCol] = c.ColumnName;
                }
                // for each row of data...
                int iRow = 0;
                foreach (DataRow r in dt.Rows)
                {
                    iRow++;

                    // add each row's cell data...
                    iCol = 0;
                    foreach (DataColumn c in dt.Columns)
                    {
                        iCol++;
                        excel.Cells[iRow + 1, iCol] = r[c.ColumnName];
                    }
                }

                // Global missing reference for objects we are not defining...
                object missing = System.Reflection.Missing.Value;

                // If wanting to Save the workbook...
                workbook.SaveAs("MyExcelWorkBook.xls",
                    Excel.XlFileFormat.xlXMLSpreadsheet, missing, missing,
                    false, false, Excel.XlSaveAsAccessMode.xlNoChange,
                    missing, missing, missing, missing, missing);

                // If wanting to make Excel visible and activate the worksheet...
                excel.Visible = true;
                Excel.Worksheet worksheet = (Excel.Worksheet)excel.ActiveSheet;
                ((Excel._Worksheet)worksheet).Activate();

                // If wanting excel to shutdown...
                ((Excel._Application)excel).Quit();
            }
ddanbe commented: Nice SPAM counter! +5
DdoubleD 315 Posting Shark

Here are a couple of SQL reference sites you may want to bookmark:

1keydata.com

w3schools.com

DdoubleD 315 Posting Shark

Here are a couple of SQL reference sites you may want to bookmark:

1keydata.com

w3schools.com

DdoubleD 315 Posting Shark

I don't think you should be remapping keys across the entire system, unless you are creating a key mapping program that the user is in complete control over, including the ability to restore all previous/normal key mappings.

Using the RegisterHotKey function won't work for you because it fails if the mapping is already defined.

There is no easy way to do this that I am aware of. In theory, you could subclass the OS message loop to capture these keys and then redirect the message (using SendMessage ) as some other function.

I know you indicated "without using hooks", but if you are still interested in doing this, here are some basic links and further discussion:

Basic discussion of .NET Subclassing and OS Message Queue...

Subclassing Forms and Controls...

Simple hook installation with windows handle...

Keyboard hook example using WM_HOTKEY

DdoubleD 315 Posting Shark

Try this MSDN link for specs and HOW TO examples: DataGrid Control. Also try googling and CodePlex.com for further examples.

DdoubleD 315 Posting Shark

To clarify, are you wanting to change these keys for the system, or just within/for your running application?

DdoubleD 315 Posting Shark

>>In the code that follows, you will find my changes easily, because it is practically the only code that has comments!
:( I am pretty bad about not commenting

Doh!--LOL.. Confessions are supposed to be good for the soul though,;)