alderaan's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
6 (0.01 per day)
Joined:
20-November 12
Profile Views:
111
Last Active:
User is offline Nov 21 2012 11:57 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   alderaan has not set their status

Posts I've Made

  1. In Topic: Cannot get respons when enter-key is pressed in textbox1.

    Posted 21 Nov 2012

    View PostMomerath, on 21 November 2012 - 11:26 AM, said:

    If you've set the AcceptButton property of the form then the enter key will be captured by the form and not any of the controls on the form.


    OK!
    Thank you. I got it.
    I have to get a button to the form and then set the "AcceptButton" property to use "button1" of the form - not the button property.
    Then i can use Enter-key triggering the "button1" button.
    I donīt really want a extra button in my form, and i think itīs a little crazy, but i works. No other methods work for me.

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

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

    private void button1_Click(object sender, EventArgs e)
    {
    string sometext;
    sometext = textBox1.Text;
    MessageBox.Show("You Wrote " + sometext);

    //Compare entered text to a string

    if(sometext=="hello world")
    MessageBox.Show("string match");
    else
    MessageBox.Show("string mismatch");
    }

    }
    }

    ]/code]
  2. In Topic: Cannot get respons when enter-key is pressed in textbox1.

    Posted 21 Nov 2012

    I get no respons at all.
    Nothing is happening.
    No error message.

    If i use textBox1_TextChanged method i get a respons
    in this example the key a is pressed.
    What i want to do is write some text in textBox1 and press enter,
    and then treat the text in textBox1 as a string.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace enterkey
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
    
            }
    
            private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                    MessageBox.Show("enter is pressed");
            }
    
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                if(textBox1.Text == "a")
                    MessageBox.Show("a is pressed");
            }
     
    
        }
    }
    
    
  3. In Topic: Using backgroundworker to report progress with progressbar.

    Posted 21 Nov 2012

    Why would i need two progressbars.
    Well i figured it out by myself.
    This is the correct code (part of the modified code):

    
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                // Set Minimum to 0 to represent the first row beeing processed.
                progressBar1.Minimum = 0;
                // Set the initial value of the ProgressBar.
                progressBar1.Value = 0;
                // Set the Step property to a value of 1 to represent each row beeing processed.
                progressBar1.Step = 1;
    
    
                 // Calculate number of rows.
                System.Int32 calculaterows = dataGridViewDump.Rows.Count;
    
                // Set Maximum to the total number of rows beeing processed.
                progressBar1.Maximum = calculaterows-1;        
            }
    
            void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
            {
                
                Excel.Application xlApp;
                Excel.Workbook xlWorkBook;
                Excel.Worksheet xlWorkSheet;
                object misValue = System.Reflection.Missing.Value;
    
                xlApp = new Excel.Application();
    
                xlWorkBook = xlApp.Workbooks.Add(misValue);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
    
                int i = 0;
                int j = 0;
    
                    for (j = 0; j <= dataGridViewDump.ColumnCount - 1; j++)
                    {
                        xlWorkSheet.Cells[1, j + 1] = dataGridViewDump.Columns[j].Name;
                    }
    
                    for (i = 0; i <= dataGridViewDump.RowCount - 1; i++)
                    {
                        for (j = 0; j <= dataGridViewDump.ColumnCount - 1; j++)
                        {
                            DataGridViewCell cell = dataGridViewDump[j, i];
                            xlWorkSheet.Cells[i + 2, j + 1] = cell.Value;
    
                            backgroundWorker1.ReportProgress(i);
                        }
                    }
    
     
                System.Threading.Thread.Sleep(1000);
    
                MessageBox.Show("Excel file created at desktop as dbasedump.xls");
    
            }
         }
    
    
  4. In Topic: Using backgroundworker to report progress with progressbar.

    Posted 20 Nov 2012

    No other problems.

    How do i report progress of i and j?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

alderaan hasn't added any friends yet.

Comments

alderaan has no profile comments yet. Why not say hello?