Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Data Bindings

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul - 24 May 2007 14:49 GMT
Hi, I have a project configured as follows:

Main form with a tabcontrol with 1 tab page and a panel with some text boxes
in. This form also has some bindingsources dropped onto the form.

When a selection is made the program instantiates a new class which creates
several tabs on the main form each with a datagridview on. As you click on
each tab a datatable is populated and bound to the datagridview. This all
works ok.

I am then trying to bind the data from the datagridview to the relevant
textbox on the main form from my new class. The code executes without error
but no data shows in the textboxes. I have tried performing the databindings
in my new class or the main one but no difference.

If I move all my methods into the main class then the databindings work ok.

I hope this makes sense. Any ideas?
Nicholas Paldino [.NET/C# MVP] - 24 May 2007 17:14 GMT
Paul,

   Can you show some of the code you are using to perform the databinding,
both to the grids and to the textboxes?  My initial guess is that you are
using the wrong binding source.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi, I have a project configured as follows:
>
[quoted text clipped - 15 lines]
>
> I hope this makes sense. Any ideas?
Paul - 24 May 2007 17:56 GMT
Hi, as requested here are the code snippets

this is in the main class

public void BindCallData(string property, object dataSource)
{
tbxCallReference.DataBindings.Add(property, dataSource,
"Call_Reference_Number");
tbxCallDetails.DataBindings.Add(property, dataSource, "Call_Requirements");

}

this is in my second class

public void tabControlCalls_Selected(object sender, TabControlEventArgs e)
{
int x = e.TabPageIndex;

switch (x)
{
case 0:
 break;

 case 1:

ClearBindings();
IPodBindingSource.DataSource = DtNewCallsData;
DgvNewCalls.DataSource = IPodBindingSource;
BindCallData("Text", IPodBindingSource);
FormatCallsGrid(dgvNewCalls);

break;

}

> Paul,
>
[quoted text clipped - 21 lines]
>>
>> I hope this makes sense. Any ideas?
Paul - 24 May 2007 20:53 GMT
Hi, just in case this also helps this is how the second class is called and
how the tabs are added to the tabcontrol.

private void doIpod()
{
Apple.iPOD IPod = new Equinox_Call_Manager.Apple.iPOD();

this.tabControlCalls.Selected += new TabControlEventHandler
(IPod.tabControlCalls_Selected);

tabControlCalls.TabPages.Add(IPod.ShowNewCallsTab());
tabControlCalls.TabPages.Add(IPod.ShowChase1CallsTab());
tabControlCalls.TabPages.Add(IPod.ShowChase2CallsTab());
}

Also how a tabpage is formed:-

public TabPage ShowNewCallsTab()
{

TabPage newTab = new TabPage();
dgvNewCalls = new DataGridView();

dgvNewCalls.AllowUserToAddRows = false;
dgvNewCalls.AllowUserToDeleteRows = false;
dgvNewCalls.ColumnHeadersHeightSizeMode =
DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
dgvNewCalls.AllowUserToResizeColumns = false;
dgvNewCalls.AllowUserToResizeRows = false;
dgvNewCalls.RowHeadersVisible = false;
dgvNewCalls.ScrollBars = ScrollBars.Vertical;
dgvNewCalls.Dock = System.Windows.Forms.DockStyle.Fill;
dgvNewCalls.Location = new System.Drawing.Point(0, 0);
dgvNewCalls.Name = "dgvNewCalls";
dgvNewCalls.ReadOnly = true;
dgvNewCalls.Size = new System.Drawing.Size(331, 588);
dgvNewCalls.TabIndex = 0;
dgvNewCalls.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvNewCalls.MultiSelect = false;

newTab.Controls.Add(dgvNewCalls);
newTab.Location = new System.Drawing.Point(4, 22);
newTab.Name = "NewCalls";
newTab.Size = new System.Drawing.Size(993, 588);
newTab.TabIndex = 1;
newTab.Text = "New Calls";
newTab.UseVisualStyleBackColor = true;

return newTab;
}

> Paul,
>
[quoted text clipped - 21 lines]
>>
>> I hope this makes sense. Any ideas?
Paul - 25 May 2007 16:45 GMT
Hi Nicholas, have you had a chance to look at this problem yet.

Any advice would be much appreciated.

Thanks again

Paul

> Paul,
>
[quoted text clipped - 21 lines]
>>
>> I hope this makes sense. Any ideas?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.