Differences between revisions 3 and 11 (spanning 8 versions)
Revision 3 as of 2009-03-04 21:54:03
Size: 1187
Editor: 24-183-238-75
Comment:
Revision 11 as of 2009-03-09 00:51:46
Size: 2600
Editor: 24-183-238-75
Comment:
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:
 1. Double Clicked on DGV object to create a CellContentClick event handler. To start with I'll just do a MessageBox as shown in Table I Below
 1.
  1. A BindingSource component is added at the bottom. Change the Sort Property to: TopicText ASC
 1. Double Clicked on DGV object to create a CellContentClick event handler. To start with I'll just do a MessageBox as shown in Section 1 of the code below
 1. Added another TableAdaptor for beliefs, as well as a BindingSource and BindingNavigator
  1. Have the TableAdaptor Fill the bibleDB [[DataSet|DataSet in on form load.]]
  1. Section 1 shows that we also will filter this binding source with the topic key.
 1. We then added a web browser control and a button to retrieve a verse from biblegateway.com
 1. NEXT: Make sure that data is persisted in the database.
Line 17: Line 22:
if (Utilities.IsANonHeaderLinkCell((DataGridView)sender, e))
            {
                string cellValue = (string)dgvTopics.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                MessageBox.Show(cellValue);
            }
{{{
//Section 1: Accessing the selected value
if (Utilities.IsANonHeaderLinkCell(()sender, e))
 {
    int topicKey = (int)dgvTopics.Rows[e.RowIndex].Cells[0].Value;
    this.beliefsBindingSource.Filter = "TopicKey = " + topicKey;
 }
Line 23: Line 30:
//Section 2: Utility Function used in Section 1
public static bool IsANonHeaderLinkCell(DataGridView dgv, DataGridViewCellEventArgs cellEvent)
{
    if (dgv.Columns[cellEvent.ColumnIndex] is DataGridViewLinkColumn && cellEvent.RowIndex != -1)
    { return true; }
    else { return false; }
}

//Section 3: Added to MainForm_Load to sort grid
this.dgvTopics.Sort(dgvTopics.Columns[1], ListSortDirection.Ascending);

//Section 4: filter verses based on belief row that is currently displayed - not easy to find!

private void txtBeliefsText_TextChanged(object sender, EventArgs e)
{
    //How to get other fields in the row currently displaying a field in a bound TextBox
    int newBeliefKey = (int)((DataRowView)beliefsBindingSource.Current).Row["BeliefKey"];
    this.versesBindingSource.Filter = "BeliefKey = " + newBeliefKey;
}
}}}
Line 24: Line 51:
 . [[scot/PasswordList]]

Dr. A

More info about Dr. "A" and his Wife Dr. Anderson can be found at http://www.scotnpatti.com.

Current Projects

Bible Beliefs Database Project

  1. Add the connection to the Data Connections in Server Explorer
  2. Add a data set item to the project. This is a nice gui place to create the data set. Drag and drop the tables on the page and you will build yourself a nice database diagram similar to what you would do in Visio.
  3. Next I added a DataGridView Object, bound it to the TopicTextViewOrdered and changed the column type to DataGridViewLinkColumn.

    1. Note the contextMenuStrip should be where we click to add a new belief possibly
    2. Turned TrackVisitedState to false.

    3. A BindingSource component is added at the bottom. Change the Sort Property to: TopicText ASC

  4. Double Clicked on DGV object to create a CellContentClick event handler. To start with I'll just do a MessageBox as shown in Section 1 of the code below

  5. Added another TableAdaptor for beliefs, as well as a BindingSource and BindingNavigator

    1. Have the TableAdaptor Fill the bibleDB DataSet in on form load.

    2. Section 1 shows that we also will filter this binding source with the topic key.
  6. We then added a web browser control and a button to retrieve a verse from biblegateway.com
  7. NEXT: Make sure that data is persisted in the database.

//Section 1: Accessing the selected value
if (Utilities.IsANonHeaderLinkCell(()sender, e))
 {
    int topicKey = (int)dgvTopics.Rows[e.RowIndex].Cells[0].Value;
    this.beliefsBindingSource.Filter = "TopicKey = " + topicKey;
 }

//Section 2: Utility Function used in Section 1
public static bool IsANonHeaderLinkCell(DataGridView dgv, DataGridViewCellEventArgs cellEvent)
{
    if (dgv.Columns[cellEvent.ColumnIndex] is DataGridViewLinkColumn && cellEvent.RowIndex != -1)
    { return true; }
    else { return false; }
}

//Section 3: Added to MainForm_Load to sort grid
this.dgvTopics.Sort(dgvTopics.Columns[1], ListSortDirection.Ascending);

//Section 4: filter verses based on belief row that is currently displayed - not easy to find!

private void txtBeliefsText_TextChanged(object sender, EventArgs e)
{
    //How to get other fields in the row currently displaying a field in a bound TextBox
    int newBeliefKey = (int)((DataRowView)beliefsBindingSource.Current).Row["BeliefKey"];
    this.versesBindingSource.Filter = "BeliefKey = " + newBeliefKey;
}


CategoryHomepage

scot (last edited 2021-02-25 00:01:31 by 68)