Solved

C# Windows app - Current Changed not working

Posted on 2011-09-26
5
304 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Good! have a nice day
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

10 Experts available now in Live!

Get 1:1 Help Now