Re: DataGrid Problem by Norman
Norman
Thu Jan 08 11:28:14 CST 2004
OK, try this:
Move grdLeft.DataSource further down, to after GridColumns and
GridTableStyle are programmingly defined. The problem could be: you set
DataSource too early that data binding occurs before your tablestyle and
gridColumn is created!
"Trey" <weaver@nc.rr.com> wrote in message
news:%23p2KR1W1DHA.2480@TK2MSFTNGP10.phx.gbl...
> Both of these are there. Now what should I look for?
>
> "Norman Yuan" <normanyuan@RemoveThis.shaw.ca> wrote in message
> news:sq%Kb.17864$X%5.7324@pd7tw2no...
> > Make sure the DataTable, which the DataGrid's datasource- dv is based
on,
> > has TableName "Sevices" and there is a DataColumn called
"ColumnLeft1Name"
> > in the DataTable.
> >
> > It is obvious for me that when data binding occurs, the datagrid does
not
> > find mapped table name, or mapped column name, thus you get a blank
column
> > in grid.
> >
> > "Trey" <weaver@nc.rr.com> wrote in message
> > news:OgwrhkW1DHA.1764@TK2MSFTNGP10.phx.gbl...
> > > I am trying to create and load a datagrid at runtime. I am not having
> any
> > > luck. The Datagrid shows up and one column which is about 50 wide
shows
> > up
> > > with no header. What am I doing wrong? Here is my code.
> > >
> > > dgcColLeft1 = new DataGridTextBoxColumn();
> > > dgtsGridLeft = new DataGridTableStyle();
> > > grdLeft = new DataGrid();
> > >
> > > // Make the Grid
> > > grdLeft.Location = new System.Drawing.Point(6, 6);
> > > grdLeft.Size = new System.Drawing.Size(300, 300);
> > > grdLeft.Dock = DockStyle.Fill;
> > > grdLeft.CaptionVisible = false;
> > > grdLeft.DataMember = "";
> > > grdLeft.DataSource = dv; //dataview
> > > grdLeft.Name = "GridLeft";
> > > grdLeft.TableStyles.Add(dgtsGridLeft); // add table styles
> > >
> > > // make the styles
> > > dgtsGridLeft.DataGrid = this.grdLeft;
> > > dgtsGridLeft.MappingName = "Services";
> > > dgtsGridLeft.GridColumnStyles.Add(dgcColLeft1); // add the column
> > >
> > > // make the column
> > > dgcColLeft1.Format = "";
> > > dgcColLeft1.FormatInfo = null;
> > > dgcColLeft1.HeaderText = "Test this";
> > > dgcColLeft1.MappingName = "ColumnLeft1Name";
> > > dgcColLeft1.NullText = "";
> > > dgcColLeft1.Width = 125;
> > >
> > >
> >
> >
>
>