Friday, September 15, 2017

Knowledge during Window App Development



Login Form

1. Objective- Press Enter in Textbox then go to Next Control
Process- If we write Key_Up event for textbox then issue arises.
Issue- Scenario is when i clicked submit button then alert message comes and cursor goes to invalid textbox and when i pressed enter to close alert popup then cursor move to next control from invalid textbox.
Solution- We write Key_Down event

2. Objective- Stop beep Sound when move to next control or Press Enter Button
Solution- e.SuppressKeyPress=true; e.Handled = true; These two lines write under Key_Down event.

3. Issue- In a form, there is a datagridview and two button New and Edit. When i click New button then New form shows. And when i close New form then cursor focus does not go to datagridview.
Solution- When click New button then write first line datagridview focus and then send to other form.

4. Objective- Best way to search text in datagridview
Solution- Exact matches: (dataGridView1.DataSource as DataTable).DefaultView.RowFilter = string.Format("Name='{0}'", searchTextBox.Text);
Contains matches: (dataGridView1.DataSource as DataTable).DefaultView.RowFilter = string.Format("Name LIKE '%{0}%'", searchTextBox.Text);

5. Objective- Best way to fill items in Dropdown or Combobox
Solution-(1)    string[] items = new string[dt.Rows.count];
                       for(int i=0; i < dt.Rows.Count; i++)
                            items[i] = dt.Rows[i][j].ToString();
                       ddl.Items.AddRange(items);

               (2)   ddl.DataSource = dt;
                       ddl.DisplayMember = "Column Name";
                       ddl.ValueMember = "Column Name";

6. Info - Difference Between IsDigit() and IsNumber()
Answer - https://stackoverflow.com/questions/228532/difference-between-char-isdigit-and-char-isnumber-in-c-sharp   To get answer please read comments by "Matas Vaitkevicius".

No comments:

Post a Comment