I have my ultra grid set as follows:
this.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
This is good because it ensures that all the columns use up the space in my ultra grid.
However, when the user resizes a column in the ultra grid it is quite jarring because all of the columns resize as well. This leads to the column (the one that's being resized) to not even be resized to the position that the user indicated (sometimes it's truncated or elongated).
I would prefer the resizing method that the following line uses:
this.DisplayLayout.AutoFitStyle = AutoFitStyle.None;
The problem with this however is that the columns will not take up all the space in the Ultra Grid.
Is there some other method I can make use of that I am unaware of?
The fact that the column is not sizing to the correct position of the mouse may be a limitation of the grid, but it could also be a bug.
It depends on the other columns and any MinWidth you may have a applied, plus any minimum widths that might be enforced for other reasons.
What version of the controls are you using?
My hunch is that it is not a MinWidth issue, as I have experienced these in the past - though I'm not 100% certain.
The version of the control I am using is 8.3
It would be great if you could post a small sample project that we could run to demonstrate the error. With a code snippet, there are just too many unknowns.
Yes the RowLayouts are very complex. Icreate a hierarchical view of the datasets. My hunch is that it IS a bug. The code is pretty complex I'm not sure if you can reproduce because it may be hard to figure out, but I'll post it anyways:
First I have to create a hierarchical data set:
private DataSet CreateHierarchicalDataSet(DataTable v_DataTable, Int32 v_highestLevel)
{
// declare a new DataSet
DataSet hierarchicalDataSet = new DataSet("HierarchicalDataSet");
// pass DataTable for each hierarchical level
Int32 intLevel = default(Int32);
for (intLevel = 0; intLevel <= v_highestLevel; intLevel++)
// pass DataTable and extract rows for this level
DataRow[] levelDataRows = null;
levelDataRows = v_DataTable.Select("SortLevel=" + intLevel.ToString());
// test to see if any rows were selected
if ((levelDataRows != null))
// create a new data table and add the rows and columns
DataTable levelDataTable = new DataTable();
levelDataTable = v_DataTable.Clone();
levelDataTable.TableName = "SortLevel" + intLevel.ToString();
DataRow dataRow = null;
foreach (DataRow dataRow_loopVariable in levelDataRows)
dataRow = dataRow_loopVariable;
DataColumn dataColumn = null;
DataRow newDataRow = levelDataTable.NewRow();
foreach (DataColumn dataColumn_loopVariable in v_DataTable.Columns)
dataColumn = dataColumn_loopVariable;
newDataRow[dataColumn.ColumnName] = dataRow[dataColumn.ColumnName];
}
levelDataTable.Rows.Add(newDataRow);
// create a primary key and add to the data table
DataColumn[] Keys = new DataColumn[1];
Keys[0] = levelDataTable.Columns["SortID"];
levelDataTable.PrimaryKey = Keys;
// add table to DataSet
hierarchicalDataSet.Tables.Add(levelDataTable);
// if this is >= level 1 then create and add relationship
if (intLevel >= 1)
Int32 intParentLevel = intLevel - 1;
string strThisLevel = "SortLevel" + intLevel.ToString();
string strParentLevel = "SortLevel" + intParentLevel.ToString();
DataRelation relLevel = new DataRelation(strThisLevel, hierarchicalDataSet.Tables[strParentLevel].Columns["SortID"], hierarchicalDataSet.Tables[strThisLevel].Columns["SortIDLink"]);
hierarchicalDataSet.Relations.Add(relLevel);
return hierarchicalDataSet;
Sort level = depth of the tree.
SortID is the primary key
SortIDLink is the row's link to a parent node (if not the top most row [SortLevel = 0]).
In the InitializeRow Event:
void TransactionGrid_InitializeRow(object sender, InitializeRowEventArgs e)
// attempt to turn off expansion indicator
if (e.Row.HasChild())
e.Row.ExpansionIndicator = ShowExpansionIndicator.Always;
else
e.Row.ExpandAll();
//Comment Column
Once the dataTable is populated I will construct a demo table:
public DataSet MakeTable(DataSet dtsTemp)
DataTable dt = new DataTable();
dt.TableName = "Clients";
dtsTemp.Tables.Add(dt);
dt.Columns.Add("Amount", typeof(System.Int32));
dt.Columns.Add("Name", typeof(System.String));
dt.Columns.Add("SortID", typeof(System.Int32));
dt.Columns.Add("SortIDLink", typeof(System.Int32));
dt.Columns.Add("SortLevel", typeof(System.Int32));
dt.Rows.Add(new object[] { 800, "Richard P. Joines", 0 , -1, 0});
dt.Rows.Add(new object[] { 644, "Jimmy Yanzee", 1, 0, 1 });
dt.Rows.Add(new object[] { 646, "Yiminey Zoo", 2, 0, 1 });
dt.Rows.Add(new object[] { 234, "Lead Saunders", 3, 0, 1 });
dt.Rows.Add(new object[] { 754, "Rick H. T.", 4, -1, 0 });
dt.Rows.Add(new object[] { 754, "Nancy Red", 5, 4, 1 });
dt.Rows.Add(new object[] { 346, "Earl Bwon", 6, 5, 2 });
dt.Rows.Add(new object[] { 643, "Marvin K. Mooney", 7, 5, 2 });
return dtsTemp;
We then create a hierarchical dataset and initialize the grid:
DataSet dtsTemp = new DataSet();
transactionGrid1.DataSource = MakeTable(dtsTemp);
transactionGrid1.TransactionTableName = "Clients";
this.DataSource = CreateHierarchicalDataSet(dtsTemp.Tables["Clients"] , 3);
Well, 8.3 is pretty old, so this could easily be a bug that has been fixed along the way. But like I said, there are also so cases where the grid simply cannot handle this because of the complexity of the RowLayouts.
If you can post a small sample project demonstrating the issue, I'd be happy to take a look and try it in the latest version to see if the issue still occurs.