Data Bindings

P

Paul

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?
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
P

Paul

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;

}

Nicholas Paldino said:
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.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul said:
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?
 
P

Paul

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;
}





Nicholas Paldino said:
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.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul said:
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?
 
P

Paul

Hi Nicholas, have you had a chance to look at this problem yet.

Any advice would be much appreciated.

Thanks again


Paul

Nicholas Paldino said:
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.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top