Solved

C# Windows app - Current Changed not working

Posted on 2011-09-26
5
305 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Service to Receive TCP Packets 4 123
How to iterate over object and get property name and value 4 26
Excel file not created as expected 7 50
Runtime Error 2 28
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now