Newline in constant error
-
It would help if you posted the code where the error occurs! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
It would help if you posted the code where the error occurs! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Thanks David, i close the Visual Studio and reopen, everything's just fine then, sounds weird though.. Thanks But i have another question, i wanna apply column style to one of the columns in my table, i wanna hide one column but setting its width to zero, i have five datacolumn object, but i only have one gridcolumnstyle with mapping name set to one of the column name i wanna hide. but the style doesn't apply, the column is not hidden. how am i goin to hide it?
-
Thanks David, i close the Visual Studio and reopen, everything's just fine then, sounds weird though.. Thanks But i have another question, i wanna apply column style to one of the columns in my table, i wanna hide one column but setting its width to zero, i have five datacolumn object, but i only have one gridcolumnstyle with mapping name set to one of the column name i wanna hide. but the style doesn't apply, the column is not hidden. how am i goin to hide it?
You hide the column by setting it's width to 0, but since you haven't supplied any code, I can't tell you what your doing wrong. So, here's an example:
private void HideColumnOfDataSet()
{
System.Data.DataTable points = new System.Data.DataTable("Points");
points.Columns.Add(new DataColumn("X", typeof(int)));
points.Columns.Add(new DataColumn("Y", typeof(int)));
points.Rows.Add(new object[]{1, 2});
points.Rows.Add(new object[]{3, 5});
dataGrid1.DataSource = points;
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Points";
dataGrid1.TableStyles.Add(tableStyle);
dataGrid1.TableStyles["Points"].GridColumnStyles["X"].Width = 0;
}RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
You hide the column by setting it's width to 0, but since you haven't supplied any code, I can't tell you what your doing wrong. So, here's an example:
private void HideColumnOfDataSet()
{
System.Data.DataTable points = new System.Data.DataTable("Points");
points.Columns.Add(new DataColumn("X", typeof(int)));
points.Columns.Add(new DataColumn("Y", typeof(int)));
points.Rows.Add(new object[]{1, 2});
points.Rows.Add(new object[]{3, 5});
dataGrid1.DataSource = points;
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Points";
dataGrid1.TableStyles.Add(tableStyle);
dataGrid1.TableStyles["Points"].GridColumnStyles["X"].Width = 0;
}RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
i get null reference exception in this line this.dataGrid1.TableStyles["Students"].GridColumnStyles["Password"].Width = 0; how?
I can't tell without seeing the rest of your code in that block. Most likely, you're missing a 'new' somewhere. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
I can't tell without seeing the rest of your code in that block. Most likely, you're missing a 'new' somewhere. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
i get null reference exception in this line this.dataGrid1.TableStyles["Students"].GridColumnStyles["Password"].Width = 0; how?
Accessing indexes requires that an object at that index (or with that index keyword, like the table style or column style name above) exists. If it doesn't, null is returned from the index property. When you try to call a method or access a property on null, you get a
NullReferenceException
.Microsoft MVP, Visual C# My Articles
-
I sometimes see it in a perfectly valid line of code. I simply cut and re-paste the line and the compiler is then happy!