SVN r1104
SVN-Revision: r1104
This commit is contained in:
@@ -405,61 +405,70 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
private void CalcPopupLocation()
|
||||
{
|
||||
this._popup.Parent = this.GetParent(this.Parent);
|
||||
|
||||
Form form = this._popup.Parent as Form;
|
||||
if (form != null)
|
||||
try
|
||||
{
|
||||
int iTop = this.Top + this.Height;
|
||||
int iLeft = this.Left;
|
||||
System.Windows.Forms.Control ctr = this.Parent;
|
||||
this._popup.Parent = this.GetParent(this.Parent);
|
||||
|
||||
while (ctr != form)
|
||||
Form form = this._popup.Parent as Form;
|
||||
if (form != null)
|
||||
{
|
||||
iTop += ctr.Top;
|
||||
iLeft += ctr.Left;
|
||||
ctr = ctr.Parent;
|
||||
}
|
||||
int iTop = this.Top + this.Height;
|
||||
int iLeft = this.Left;
|
||||
System.Windows.Forms.Control ctr = this.Parent;
|
||||
|
||||
if (iTop + this.Height + this._popup.Height > ctr.Height)
|
||||
{
|
||||
if (iTop - this.Height > ctr.Height - iTop)
|
||||
while (ctr != form)
|
||||
{
|
||||
if (this._popup.Height > iTop - this.Height)
|
||||
iTop += ctr.Top;
|
||||
iLeft += ctr.Left;
|
||||
ctr = ctr.Parent;
|
||||
}
|
||||
|
||||
if (iTop + this.Height + this._popup.Height > ctr.Height)
|
||||
{
|
||||
if (iTop - this.Height > ctr.Height - iTop)
|
||||
{
|
||||
this._popup.Height = iTop - this.Height;
|
||||
iTop = 0;
|
||||
if (this._popup.Height > iTop - this.Height)
|
||||
{
|
||||
this._popup.Height = iTop - this.Height;
|
||||
iTop = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iTop = iTop - this.Height - this._popup.Height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iTop = iTop - this.Height - this._popup.Height;
|
||||
this._popup.Height = ctr.Height - iTop - 30;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (iLeft + this._popup.Width > ctr.Width)
|
||||
{
|
||||
this._popup.Height = ctr.Height - iTop - 30;
|
||||
}
|
||||
}
|
||||
if (iLeft + this._popup.Width > ctr.Width)
|
||||
{
|
||||
if (iLeft + this.Width > ctr.Width - iLeft)
|
||||
{
|
||||
if (this._popup.Width > iLeft + this.Width)
|
||||
if (iLeft + this.Width > ctr.Width - iLeft)
|
||||
{
|
||||
this._popup.Width = iLeft + this.Width;
|
||||
iLeft = 0;
|
||||
if (this._popup.Width > iLeft + this.Width)
|
||||
{
|
||||
this._popup.Width = iLeft + this.Width;
|
||||
iLeft = 0;
|
||||
}
|
||||
else
|
||||
iLeft = iLeft + this.Width - this._popup.Width;
|
||||
}
|
||||
else
|
||||
iLeft = iLeft + this.Width - this._popup.Width;
|
||||
this._popup.Width = ctr.Width - iLeft - 30;
|
||||
}
|
||||
else
|
||||
this._popup.Width = ctr.Width - iLeft - 30;
|
||||
}
|
||||
|
||||
this._popup.Left = iLeft;
|
||||
this._popup.Top = iTop;
|
||||
this._popup.Left = iLeft;
|
||||
this._popup.Top = iTop;
|
||||
}
|
||||
this._popup.BringToFront();
|
||||
}
|
||||
this._popup.BringToFront();
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:</para>
|
||||
@@ -1150,68 +1159,80 @@ namespace Lskj.Control
|
||||
{
|
||||
this.Invoke((EventHandler)delegate
|
||||
{
|
||||
int calcLen = this.Popup.GridViewObj.DataRowCount > 20 ? 20 : this.Popup.GridViewObj.DataRowCount;
|
||||
DataTable table = this.Popup.GridControlObj.DataSourceTable();
|
||||
|
||||
bool hasReamrkField = table.Columns.Contains(RemarkField);
|
||||
int iValueWidth = 0, iTextWidth = 0, iRemarkWidth = 0, iOtherWidth = 0;
|
||||
int iIndexWidth = popupObj.GridViewObj.IndicatorWidth;
|
||||
|
||||
for (int i = 0; i < calcLen; i++)
|
||||
try
|
||||
{
|
||||
string valueValue = ValueMember.Substring(0, 1) != "_" ? table.Rows[i][ValueField] + "" : "";
|
||||
string textValue = TextMember.Substring(0, 1) != "_" ? table.Rows[i][TextMember] + "" : "";
|
||||
string remarkValue = hasReamrkField ? table.Rows[i][RemarkField] + "" : "";
|
||||
if (this.Popup == null) return;
|
||||
int calcLen = this.Popup.GridViewObj.DataRowCount > 20 ? 20 : this.Popup.GridViewObj.DataRowCount;
|
||||
DataTable table = this.Popup.GridControlObj.DataSourceTable();
|
||||
|
||||
int valueWidth = GraphicsText.GetTextWidth(popupObj.GridControlObj, valueValue);
|
||||
int textWidth = GraphicsText.GetTextWidth(popupObj.GridControlObj, textValue);
|
||||
int remarkWidth = GraphicsText.GetTextWidth(popupObj.GridControlObj, remarkValue);
|
||||
bool hasReamrkField = table.Columns.Contains(RemarkField);
|
||||
int iValueWidth = 0, iTextWidth = 0, iRemarkWidth = 0, iOtherWidth = 0;
|
||||
int iIndexWidth = popupObj.GridViewObj.IndicatorWidth;
|
||||
|
||||
if (iValueWidth < valueWidth) iValueWidth = valueWidth;
|
||||
if (iTextWidth < textWidth) iTextWidth = textWidth;
|
||||
if (iRemarkWidth < remarkWidth) iRemarkWidth = remarkWidth;
|
||||
}
|
||||
foreach (GridColumn col in this.Popup.GridViewObj.Columns)
|
||||
{
|
||||
if (col.FieldName.Substring(0, 1) != "_" &&
|
||||
col.FieldName.ToLower() != ValueField.ToLower() &&
|
||||
col.FieldName.ToLower() != TextMember.ToLower() &&
|
||||
col.FieldName.ToLower() != RemarkField.ToLower())
|
||||
for (int i = 0; i < calcLen; i++)
|
||||
{
|
||||
col.Width = col.GetBestWidth();
|
||||
iOtherWidth += col.Width;
|
||||
}
|
||||
}
|
||||
// 由于计算有误差,所以计算列结果都加10px
|
||||
iValueWidth = iValueWidth < 50 ? 50 : iValueWidth + 10;
|
||||
iTextWidth = iTextWidth < 50 ? 50 : iTextWidth + 10;
|
||||
string valueValue = ValueMember.Substring(0, 1) != "_" ? table.Rows[i][ValueField] + "" : "";
|
||||
string textValue = TextMember.Substring(0, 1) != "_" ? table.Rows[i][TextMember] + "" : "";
|
||||
string remarkValue = hasReamrkField ? table.Rows[i][RemarkField] + "" : "";
|
||||
|
||||
popupObj.GridViewObj.Columns[ValueMember].Width = iValueWidth;
|
||||
popupObj.GridViewObj.Columns[TextMember].Width = iTextWidth;
|
||||
if (hasReamrkField)
|
||||
{
|
||||
popupObj.GridViewObj.Columns[RemarkField].Width = iRemarkWidth;
|
||||
iRemarkWidth = iRemarkWidth + 10;
|
||||
}
|
||||
int popupWidth = iIndexWidth + iValueWidth + iTextWidth + iRemarkWidth + iOtherWidth + 40;
|
||||
if (Model != null && Model.LookUpWidth > 0)
|
||||
{
|
||||
popupWidth = iIndexWidth + Model.LookUpWidth + 5;
|
||||
}
|
||||
if (popupWidth != popupObj.Width)
|
||||
{
|
||||
if (popupWidth > _maxPopupWidth)
|
||||
{
|
||||
popupWidth = _maxPopupWidth;
|
||||
int valueWidth = GraphicsText.GetTextWidth(popupObj.GridControlObj, valueValue);
|
||||
int textWidth = GraphicsText.GetTextWidth(popupObj.GridControlObj, textValue);
|
||||
int remarkWidth = GraphicsText.GetTextWidth(popupObj.GridControlObj, remarkValue);
|
||||
|
||||
if (iValueWidth < valueWidth) iValueWidth = valueWidth;
|
||||
if (iTextWidth < textWidth) iTextWidth = textWidth;
|
||||
if (iRemarkWidth < remarkWidth) iRemarkWidth = remarkWidth;
|
||||
}
|
||||
else if (popupWidth < _minPopupWidth)
|
||||
foreach (GridColumn col in this.Popup.GridViewObj.Columns)
|
||||
{
|
||||
popupWidth = _minPopupWidth;
|
||||
if (col.FieldName.Substring(0, 1) != "_" &&
|
||||
col.FieldName.ToLower() != ValueField.ToLower() &&
|
||||
col.FieldName.ToLower() != TextMember.ToLower() &&
|
||||
col.FieldName.ToLower() != RemarkField.ToLower())
|
||||
{
|
||||
col.Width = col.GetBestWidth();
|
||||
iOtherWidth += col.Width;
|
||||
}
|
||||
}
|
||||
// 由于计算有误差,所以计算列结果都加10px
|
||||
iValueWidth = iValueWidth < 50 ? 50 : iValueWidth + 10;
|
||||
iTextWidth = iTextWidth < 50 ? 50 : iTextWidth + 10;
|
||||
|
||||
if(popupObj.GridViewObj.Columns.ColumnByFieldName(ValueMember)!=null) popupObj.GridViewObj.Columns[ValueMember].Width = iValueWidth;
|
||||
|
||||
if(popupObj.GridViewObj.Columns.ColumnByFieldName(TextMember) != null) popupObj.GridViewObj.Columns[TextMember].Width = iTextWidth;
|
||||
|
||||
if (hasReamrkField)
|
||||
{
|
||||
if (popupObj.GridViewObj.Columns.ColumnByFieldName(RemarkField) != null) popupObj.GridViewObj.Columns[RemarkField].Width = iRemarkWidth;
|
||||
iRemarkWidth = iRemarkWidth + 10;
|
||||
}
|
||||
int popupWidth = iIndexWidth + iValueWidth + iTextWidth + iRemarkWidth + iOtherWidth + 40;
|
||||
if (Model != null && Model.LookUpWidth > 0)
|
||||
{
|
||||
popupWidth = iIndexWidth + Model.LookUpWidth + 5;
|
||||
}
|
||||
if (popupWidth != popupObj.Width)
|
||||
{
|
||||
if (popupWidth > _maxPopupWidth)
|
||||
{
|
||||
popupWidth = _maxPopupWidth;
|
||||
}
|
||||
else if (popupWidth < _minPopupWidth)
|
||||
{
|
||||
popupWidth = _minPopupWidth;
|
||||
}
|
||||
}
|
||||
popupObj.Width = popupWidth;
|
||||
this.CalcPopupLocation();
|
||||
this._Handed = false;
|
||||
}
|
||||
popupObj.Width = popupWidth;
|
||||
this.CalcPopupLocation();
|
||||
this._Handed = false;
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user