This commit is contained in:
@@ -740,7 +740,115 @@ namespace Volian.Controls.Library
|
||||
CellRange sel = this.Selection;
|
||||
//sel.UserData = trtb.ContentsRectangle.Height;
|
||||
|
||||
// Now see the the selected row,col is in the defined merge ranges
|
||||
// Now adjust the Height and Width in the defined merge ranges
|
||||
AdjustMergeRangeHeightWidth(r, c, trtb, tstr, AllowWidthShrink);
|
||||
|
||||
//// Now see the the selected row,col is in the defined merge ranges
|
||||
//bool mrgrows = false;
|
||||
//bool mrgcols = false;
|
||||
//foreach (CellRange cr in this.MergedRanges)
|
||||
//{
|
||||
// if (cr.Contains(r, c))
|
||||
// {
|
||||
// if (cr.c1 != cr.c2)
|
||||
// mrgcols = true; // in a range of merged columns
|
||||
// if (cr.r1 != cr.r2)
|
||||
// mrgrows = true; // in a range of merged rows
|
||||
// continue;
|
||||
// }
|
||||
//}
|
||||
//if (!mrgcols || !mrgrows)
|
||||
//{
|
||||
// // IF the row of the selected cell is NOT in merged range
|
||||
// // then go ahead and adjust the row height (if needed)
|
||||
// if (!mrgrows)
|
||||
// {
|
||||
// // add adjustment for grid and cell borders
|
||||
// int newheight = trtb.Height + 3;
|
||||
|
||||
// //Console.WriteLine("{0} {1} {2} '{3}'", r, c, newheight,trtb.Text);
|
||||
// if (newheight > this.Rows[r].Height)
|
||||
// {
|
||||
// //Console.WriteLine("1 Row {0} Old Height = {1}, New Height = {2}", r, Rows[r].Height, newheight);
|
||||
// this.Rows[r].Height = newheight;
|
||||
// }
|
||||
// }
|
||||
// // IF the column of the selected cell is NOT in merged range
|
||||
// // then go ahead and adjust the column width (if needed)
|
||||
// if (!mrgcols)
|
||||
// {
|
||||
// // add adjustment for grid and cell borders
|
||||
// int newwidth = trtb.Width + 2;
|
||||
|
||||
// if (newwidth > this.Cols[c].Width || AllowWidthShrink || r == 0)
|
||||
// this.Cols[c].Width = newwidth;
|
||||
// }
|
||||
//}
|
||||
//if (mrgrows && tstr != null)
|
||||
//{
|
||||
// CellRange cr = GetMergedRange(r, c);
|
||||
// //Console.WriteLine("grid[{0},{1}] merge = {2}", r, c,cr);
|
||||
// if (cr.r1 == r && cr.c1 == c)
|
||||
// {
|
||||
// // if in merged rows, then make sure the cell's height is large enough
|
||||
// string[] strary = tstr.Split("\n".ToCharArray());
|
||||
// // count number of lines of text
|
||||
// int nlines = strary.Length;
|
||||
// // count number of rows in merge range
|
||||
// int nrows = (cr.r2 - cr.r1) + 1;
|
||||
// //Console.WriteLine("2 Row {0} Height = {1}", cr.r1, Rows[cr.r1].Height);
|
||||
// while (nlines > nrows)
|
||||
// {
|
||||
// // add length to first row in merged range
|
||||
// int h = this.Rows[cr.r1].Height;
|
||||
// int defH = Rows.DefaultSize - 3;
|
||||
// //h = (h == -1) ? _minRowHeight * 2 : h + _minRowHeight;
|
||||
// h = (h == -1) ? (defH * 2) + 3 : h + defH;
|
||||
// //h = (h == -1) ? (Rows.DefaultSize + 2) * 2 : h + Rows.DefaultSize + 2;
|
||||
// //Console.WriteLine("3 Row {0} Old Height = {1}, New Height = {2}", cr.r1, Rows[cr.r1].Height, h);
|
||||
// this.Rows[cr.r1].Height = h;
|
||||
// nrows++;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
private void AdjustCellHeightWidth(int r, int c)
|
||||
{
|
||||
StepRTB trtb = new StepRTB();
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
bool AllowWidthShrink = false;
|
||||
trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
trtb.Clear();
|
||||
trtb.Font = this.Font;
|
||||
trtb.Rtf = (string)this[r, c];
|
||||
tstr = trtb.Text;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
AllowWidthShrink = tstr.Contains("#Link:");
|
||||
else
|
||||
{
|
||||
trtb.Text = "X"; // this is to trick steprtf in giving a char width to fit one character
|
||||
// note that a space character was too small.
|
||||
dummyCharWidth = true;
|
||||
}
|
||||
// find the needed cell width
|
||||
trtb.AdjustWidthForContent();
|
||||
|
||||
if (dummyCharWidth)
|
||||
{
|
||||
trtb.Text = ""; // clear out the dummy character before saving
|
||||
dummyCharWidth = false;
|
||||
}
|
||||
|
||||
this.Select(r, c, false);
|
||||
CellRange sel = this.Selection;
|
||||
|
||||
// Now adjust the Height and Width in the defined merge ranges
|
||||
AdjustMergeRangeHeightWidth(r, c, trtb, tstr, AllowWidthShrink);
|
||||
}
|
||||
|
||||
private void AdjustMergeRangeHeightWidth(int r, int c, StepRTB trtb, string tstr, bool AllowWidthShrink)
|
||||
{
|
||||
bool mrgrows = false;
|
||||
bool mrgcols = false;
|
||||
foreach (CellRange cr in this.MergedRanges)
|
||||
@@ -784,7 +892,6 @@ namespace Volian.Controls.Library
|
||||
if (mrgrows && tstr != null)
|
||||
{
|
||||
CellRange cr = GetMergedRange(r, c);
|
||||
//Console.WriteLine("grid[{0},{1}] merge = {2}", r, c,cr);
|
||||
if (cr.r1 == r && cr.c1 == c)
|
||||
{
|
||||
// if in merged rows, then make sure the cell's height is large enough
|
||||
@@ -799,21 +906,43 @@ namespace Volian.Controls.Library
|
||||
// add length to first row in merged range
|
||||
int h = this.Rows[cr.r1].Height;
|
||||
int defH = Rows.DefaultSize - 3;
|
||||
//h = (h == -1) ? _minRowHeight * 2 : h + _minRowHeight;
|
||||
h = (h == -1) ? (defH * 2) + 3 : h + defH;
|
||||
//h = (h == -1) ? (Rows.DefaultSize + 2) * 2 : h + Rows.DefaultSize + 2;
|
||||
//Console.WriteLine("3 Row {0} Old Height = {1}, New Height = {2}", cr.r1, Rows[cr.r1].Height, h);
|
||||
this.Rows[cr.r1].Height = h;
|
||||
nrows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//private void AdjustCellHeightWidth(int r, int c, StepRTB trtb)
|
||||
//private void AdjustCellHeightWidth(int r, int c)
|
||||
//{
|
||||
// StepRTB trtb = new StepRTB();
|
||||
// string tstr = null;
|
||||
// bool dummyCharWidth = false;
|
||||
// bool AllowWidthShrink = false;
|
||||
// trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
// trtb.Clear();
|
||||
// trtb.Font = this.Font;
|
||||
// trtb.Rtf = (string)this[r, c];
|
||||
// tstr = trtb.Text;
|
||||
// if (tstr != null && tstr.Length > 0)
|
||||
// AllowWidthShrink = tstr.Contains("#Link:");
|
||||
// else
|
||||
// {
|
||||
// trtb.Text = "X"; // this is to trick steprtf in giving a char width to fit one character
|
||||
// // note that a space character was too small.
|
||||
// dummyCharWidth = true;
|
||||
// }
|
||||
// // find the needed cell width
|
||||
// trtb.AdjustWidthForContent();
|
||||
|
||||
// if (dummyCharWidth)
|
||||
// {
|
||||
// trtb.Text = ""; // clear out the dummy character before saving
|
||||
// dummyCharWidth = false;
|
||||
// }
|
||||
|
||||
// this.Select(r, c, false);
|
||||
// CellRange sel = this.Selection;
|
||||
// //sel.UserData = trtb.ContentsRectangle.Height;
|
||||
|
||||
// // Now see the the selected row,col is in the defined merge ranges
|
||||
// bool mrgrows = false;
|
||||
@@ -838,10 +967,12 @@ namespace Volian.Controls.Library
|
||||
// // add adjustment for grid and cell borders
|
||||
// int newheight = trtb.Height + 3;
|
||||
|
||||
// //if (newheight > this.Rows[r].Height)
|
||||
// //{
|
||||
// //Console.WriteLine("{0} {1} {2} '{3}'", r, c, newheight,trtb.Text);
|
||||
// if (newheight > this.Rows[r].Height)
|
||||
// {
|
||||
// //Console.WriteLine("1 Row {0} Old Height = {1}, New Height = {2}", r, Rows[r].Height, newheight);
|
||||
// this.Rows[r].Height = newheight;
|
||||
// //}
|
||||
// }
|
||||
// }
|
||||
// // IF the column of the selected cell is NOT in merged range
|
||||
// // then go ahead and adjust the column width (if needed)
|
||||
@@ -850,7 +981,7 @@ namespace Volian.Controls.Library
|
||||
// // add adjustment for grid and cell borders
|
||||
// int newwidth = trtb.Width + 2;
|
||||
|
||||
// //if (newwidth > this.Cols[c].Width || AllowWidthShrink || r == 0)
|
||||
// if (newwidth > this.Cols[c].Width || AllowWidthShrink || r == 0)
|
||||
// this.Cols[c].Width = newwidth;
|
||||
// }
|
||||
// }
|
||||
@@ -865,6 +996,7 @@ namespace Volian.Controls.Library
|
||||
// int nlines = strary.Length;
|
||||
// // count number of rows in merge range
|
||||
// int nrows = (cr.r2 - cr.r1) + 1;
|
||||
// //Console.WriteLine("2 Row {0} Height = {1}", cr.r1, Rows[cr.r1].Height);
|
||||
// while (nlines > nrows)
|
||||
// {
|
||||
// // add length to first row in merged range
|
||||
@@ -1742,7 +1874,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
|
||||
if (!didremove)
|
||||
MessageBox.Show("Cannot Removed Part of a Row or Column.", "Invalid Selection");
|
||||
MessageBox.Show("Cannot Removed Part of a Row or Column.\n\nNote: This function allows you to delete one or more rows/columns at time.", "Invalid Selection",MessageBoxButtons.OK,MessageBoxIcon.Hand);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1796,9 +1928,11 @@ namespace Volian.Controls.Library
|
||||
trtb.AdjustWidthForContent();
|
||||
}
|
||||
this[r, c] = trtb.Rtf;
|
||||
this.ConvertTextCellToRTF(r, c);
|
||||
//this.ConvertTextCellToRTF(r, c);
|
||||
this.AdjustCellHeightWidth(r, c);
|
||||
}
|
||||
}
|
||||
FixTableCellsHeightWidth();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user