This is where I set the grid properties.
CurrencyManager cmTasks, cmDetails;
private void ServiceTask_Load(object sender, System.EventArgs e)
{
cmTasks = (CurrencyManager) this.BindingContext[dsDetails1, "task"];
cmTasks.ItemChanged += new ItemChangedEventHandler(cmTasks_ItemChanged);
cmTasks.PositionChanged += new EventHandler(cmTasks_PositionChanged);
cmDetails = (CurrencyManager) this.BindingContext[dsDetails1,
"task.tasktask-details"];
daTasks.Fill(dsDetails1,task);
daDetails.Fill(dsDetails1,task-details);
FormatTaskGrid();
private void FormatTaskGrid()
{
DataGridTableStyle tbl = new DataGridTableStyle();
tbl.MappingName = "task-details";
DataGridTextBoxColumn col;
col = new DataGridTextBoxColumn();
col.MappingName = "taskid";
col.HeaderText = "Task ID";
col.Alignment = HorizontalAlignment.Center;
col.Width = 60;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "task-desc";
col.HeaderText = "Service Description";
col.Alignment = HorizontalAlignment.Center;
col.Width = 70;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "complete-date";
col.HeaderText = "Completion Date";
col.Alignment = HorizontalAlignment.Center;
col.Width = 80;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "task-cost";
col.HeaderText = "Service Cost";
col.Alignment = HorizontalAlignment.Right;
col.Width = 90;
tbl.GridColumnStyles.Add(col);
grdTasks.TableStyles.Add(tbl);
}
Last night I came across another problem, I hope that you can advise me on
what to do! I get the following message when I compile my code:
"D:\Kennel\Owner-Info\Owner-Info\ServiceTask.cs(806):
The name 'task' does not exist in the class or namespace 'Owner.ServiceTask'"
The dataspace/class is Owner
--
Norm Bohana
W.G. Ryan MVP said:
Where are you setting the grid properties?
nbohana said:
I set the datasource and the data member for the datagrid "dsDetails1 &
task.tasktask-details"
DataRowView drvDetail;
DataView vueDetail;
public void EditDetail(CurrencyManager cm)
{
drvDetail = (DataRowView) cm.Current;
vueDetail = drvDetail.DataView;
this.BindingContext[vueDetail].Position = cm.Position;
txtSON.DataBindings.Add("Text", vueDetail, "service-order-number");
txtTaskID.DataBindings.Add("Text", vueDetail, "taskid");
txtServiceDesc.DataBindings.Add("Text", vueDetail, "task-desc");
txtCompDate.DataBindings.Add("Text", vueDetail, "complete-date");
txtServiceCost.DataBindings.Add("Text", vueDetail, "task-cost");
if (this.ShowDialog() == DialogResult.OK)
cm.EndCurrentEdit();
else
cm.CancelCurrentEdit();
}
--
Norm Bohana
:
How are you handingl the binding? Are you setting the DataSource for the
datagrid as well? Are you manually doing the binding or are you using a
BindingContext? If you can show the code that binds the controls that
work,
as well as the code for the grid, that would be very helpful. I'll be
around most of the day so if you can post it soon, I'll look into it for
you
asap.
Cheers,
Bill
I have a win form with five textbox's that get filed with data from
other
data tables. The problem is the data appears in the proper textbox, but
when
I try put it in a datagrid its like its not there. I have made a test
where
I key data into the textbox's and everything works. Please tell me how
to
fix this problem?