Solved

C# Windows app - Current Changed not working

Posted on 2011-09-26
5
310 Views
Last Modified: 2012-05-12
I am trying to populate a second data grid when the user
moves from one  row of the first grid to another row.  I tried
 using the binding source current changed thinking that this
will give me the correct data especially when the user sorts
the data.  This is what I did:
     
        void m_srcBillingAudit_CurrentChanged(object sender, EventArgs e)
        {
           
            this.dgvDaysatPatient.DataSource = null;
            DataRowView rowView = (DataRowView)this.m_srcBillingAudit.Current;
            if (rowView == null)
                return;
           
                m_dtAssets = m_Assets.FillAsset_RentalLogEndDate(rowView["MRN"].ToString(),
                Convert.ToInt32(rowView["NO"].ToString()));
            dgvDaysatPatient.DataSource = m_dtAssets;
            int sumDaysP = 0;
     }
How should I go about obtaining the row a user is now looking
at so I can properly populate the second grid?
0
Comment
Question by:LenTompkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 500 total points
ID: 36599364
Hello, that code looks fine and should do the job, just be sure that your Master DataGridView has it DataSource set to m_srcBillingAudit
0
 

Author Comment

by:LenTompkins
ID: 36599504
When the user presses a button to populate the master grid this is how I have it coded, but it
didn't help:
            m_srcBillingAudit.DataSource = m_dtBillingAudit;
            navPatients.BindingSource = m_srcBillingAudit;
            dgvPatientstoReview.DataSource = m_srcBillingAudit.DataSource;

Is this correct?
0
 

Author Comment

by:LenTompkins
ID: 36599525
Thanks I figured it out.  My Populate master grid should have looked like this:
m_srcBillingAudit.DataSource = m_dtBillingAudit;
            navPatients.BindingSource = m_srcBillingAudit;
            dgvPatientstoReview.DataSource = m_srcBillingAudit;
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 36599534
There is the problem, try:
dgvPatientstoReview.DataSource = m_srcBillingAudit;

Open in new window

I'm assuming that m_srcBillingAudit is a BindingSource Object
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 36599540
Good! have a nice day
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question