⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iwmulticolumncombobox.pas

📁 TMS IntraWEb增强控件TMSIntraWeb_v2.3.2.1_D2007.rar
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      Add('for (i=0;i<CCount;i++){');
      Add('  elRow = document.getElementById( CName + "RowNo"+i);');
      Add('  elRow.style.display = "";');
      Add('  }');
      Add('}');

      Add('function CCNormalAllRows(CCount,CName){');
      Add('for (i=0;i<CCount;i++){');
      Add('  RowID = CName + "RowNo" + i;');
      Add('el = document.getElementById(RowID);');
      Add('el.style.background = "";');
      Add('  }');
      Add('}');

      Add('function CCShowUnHighLighted(id,CCount,obj){');
      Add(' el = document.getElementById(id);');
      Add(' var isIE = navigator.appName.indexOf("Microsoft") != -1;');
      Add(' if (isIE) ');
      Add('  el.style.background = "";');
      Add(' else');
      Add('  el.style.background = obj.PopUpColor;');
      Add(' for (k=0; k<=CCount;k++)');
//      Add('   el.getElementsByTagName("font")[k].color = "black";');
      Add('   el.getElementsByTagName("TD")[k].style.color = obj.ForeColor;');
      Add(' if (obj.HighLightedRow == id)');
      Add('   obj.HighLightedRow = "";');
      Add(' }');

      Add('function CCShowHighLighted(id,obj,CCount){');
      Add(' if (obj.HighLightedRow !="")');
      Add('   CCShowUnHighLighted(obj.HighLightedRow,CCount,obj);');
      Add(' obj.HighLightedRow = id;');
      Add(' el = document.getElementById(id);');
      Add(' el.style.background = obj.ClrSel;');
      Add(' for (k=0; k<=CCount;k++)');
//      Add('   el.getElementsByTagName("font")[k].style.color = obj.ClrTextSel;');
      Add('   el.getElementsByTagName("TD")[k].style.color = obj.ClrTextSel;');
      Add('}');

      Add('function CCHighLightSelected(CName,obj,DoCase){');
      Add('for (i=0;i<obj.RCount;i++){');
      Add('  elRow = document.getElementById("val"+ CName +"RowNo"+i);');
      Add('  var editor = document.getElementById(CName + "ED");');
      Add('   if (( (elRow.innerHTML.toUpperCase()) == (editor.value.toUpperCase()) && (DoCase == false) ) || ((DoCase == true) && (( elRow.innerHTML == editor.value ))))  {');
      Add('    CCShowHighLighted(CName + "RowNo"+i,obj, obj.CCount);');
      Add('    break;');
      Add('    }');
      Add('  }');
      Add('}');

 
      Add('function CCHighLightNext(CName, obj) {');
      Add('if (obj.HighLightedRow != ""){');
      Add('  elRow = document.getElementById(obj.HighLightedRow);');
      Add('  var rIndex = elRow.id.substr(elRow.id.indexOf("RowNo")+5,elRow.id.length);');
      Add('  rIndex = parseInt(rIndex);');
      Add('   if (rIndex < obj.RCount-1){');
      Add('     nexIndex = rIndex + 1;');
      Add('     nexRow = CName + "RowNo" + nexIndex;');
      Add('     elRow = document.getElementById(nexRow);');
      Add('     while ((nexIndex < obj.RCount) && (elRow.style.display != "")){');
      Add('      nexIndex = nexIndex + 1;');
      Add('      nexRow = CName + "RowNo" + nexIndex;');
      Add('      elRow = document.getElementById(nexRow);');
      Add('     }');
      Add('     if ((nexIndex < obj.RCount) && (elRow.style.display == "")){');
      Add('       CCShowUnHighLighted(obj.HighLightedRow,obj.CCount,obj);');
      Add('       CCShowHighLighted(nexRow,obj,obj.CCount);');
      Add('     }');
      Add('   }');
      Add(' }');
      Add('}');

      Add('function CCHighLightPrevious(CName, obj) {');
      Add('if (obj.HighLightedRow != ""){');
      Add('  elRow = document.getElementById(obj.HighLightedRow);');
      Add('  var rIndex = elRow.id.substr(elRow.id.indexOf("RowNo")+5,elRow.id.length);');
      Add('  if (rIndex > 0){');
      Add('    prevIndex = rIndex - 1;');
      Add('    prevRow = CName + "RowNo" + prevIndex;');
      Add('    elRow = document.getElementById(prevRow);');
      Add('    while ((prevIndex >= 1) && (elRow.style.display != "")){');
      Add('     prevIndex = prevIndex - 1;');
      Add('     prevRow = CName + "RowNo" + prevIndex;');
      Add('     elRow = document.getElementById(prevRow);');
      Add('    }');
      Add('    if ((prevIndex >= 0) && (elRow.style.display == "")){');
      Add('      CCShowUnHighLighted(obj.HighLightedRow,obj.CCount,obj);');
      Add('      CCShowHighLighted(prevRow,obj,obj.CCount);');
      Add('    }');
      Add('  }');
      Add(' }');
      Add('}');

    end;
  end;


  function StripCRLF(s:string): string;
  begin
    while pos(#13,s) > 0 do
      delete(s,pos(#13,s),1);
    while pos(#10,s) > 0 do
      delete(s,pos(#10,s),1);
    Result := s;
  end;

begin
  if (PopUpColor <> clNone) and (PopUpColorTo <> clNone) then
    gradient := ' FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=' +
        IntToStr(1 - Integer(PopUpColorGradientDirection)) + ', StartColorStr='#39
        + HTMLClr(PopUpColor) + #39', EndColorStr='#39 + HTMLClr(PopUpColorTo) + #39');';

    gradient := gradient + ' background:'+HTMLClr(FPopUpColor)+';';

     if (Font.FontVariant = '') then
     begin
       {$IFDEF TMSIW6}
       fontstyle := ' style="' + Font.FontToStringStyle(AContext.WebApplication.Browser) + '"';
       {$ELSE}
       fontstyle := ' style="' + Font.FontToStringStyle(WebApplication.Browser) + '"';
       {$ENDIF}
     end;

  htmlres :='' +
     MakeScript
     + '<style>.testmystyle {font-family:"Verdana";font-size:15pt}</style>'#13
     + '    <input type=' + IIF(FPasswordPrompt, 'password', 'input') + ' name="' + HTMLName +'"' + ' class="'+font.FontVariant+'" id="' + HTMLName +'ED"'
     + IIF(MaxLength > 0, ' maxlength=' + IntToStr(MaxLength))
     + fontstyle
     + ' size=' + IntToStr((Width div 7)-5)
     + ' value="' + Text + '"'
     + IIF(ReadOnly, ' readonly', '')
     + ' style="width:'+inttostr(width-50)+';'
     + IIF(FFlat, ' border-style:solid;border-width:'+inttostr(FBorderWidth)+ 'px;border-color:'+HTMLClr(FBorderColor)+';')
     + '"'
     + ' onKeyPress="return '+HTMLName+'noenter(event);"'
     + ' onkeyup="'+HTMLName+'ShowLookUp(event)"'
     + ' autocomplete="off"'

     + IIF(FAlignment <> taLeftJustify,MakeAlign(FAlignment))
     + IIF(FColor <> clWindow, ' style="background-color:'+HTMLClr(FColor)+'";')
     + ' onFocus="'+HTMLName+'Focus(this)";'
     + iif(FFocusColor <> FColor,' this.style.backgroundColor = '#39+HTMLClr(FColor)+#39';','')
     + '"><BUTTON onclick="'+HTMLName+'showdivonclick()"'
     + ' style="width:18px;height:22px;vertical-align:middle;text-align:center;padding:0px;top:-3;position:relative;">'
     + '<div style=" font-family:Webdings;font-size:9pt;margin:0px;padding:0px;border:0px;margin-top:-0.2em;margin-right:-0.1em;">'
     + ' <font face="webdings">6</font></div></BUTTON>'
     + '<br>'
     + '<div class="'+font.FontVariant+'" onMouseDown="'+HTMLName+'resetdoc();" id="'+HTMLName
     + 'checklist" style="display:none; position:absolute; '+gradient
     + 'border-color:#F0F0F0;border-width:1px;border-bottom:2 outset;border-right:2 outset;border-style:solid;padding:0px;'
     + ' width:'+IntToStr(PopUpWidth)+'px;'
     //+ IIF(PopUpWidth > 0, ' width:'+IntToStr(PopUpWidth)+'px;', '')
     //+ IIF(PopUpHeight > 0, ' height:'+IntToStr(PopUpHeight)+'px;overflow:auto;', '')
     + fontstyle
     + '">';

    //ColWidth := Width div FColCount;
    S:= '';

    if PopUpHeight > 0 then
      //S:= 'overflow-y:auto; height:'+inttostr(FDropDownHeight)+'px;';
      S:= ' height:'+inttostr(PopUpHeight)+'px;';
    if PopUpWidth > 0 then
      //S:= S + 'overflow-x:auto; width:'+inttostr(FDropDownWidth)+'px;';
      S:= S + ' width:'+inttostr(PopUpWidth)+'px;';

       S := S + ' overflow:auto;';
       
    if S <>'' then
      S:= 'style="'+S+'"';

    htmlres := htmlres + '<div id="'+HTMLName+'popup" '+S+'>';
    S:= '';
 //   if FGridBorderColor <> clNone then
 //     S := 'bordercolor="'+HTMLClr(FGridBorderColor)+'"';

    gborder := '0';
    if FShowGridBorder then
      gborder := '1';

    htmlres := htmlres + '<table width="100%" style="color:'+HTMLClr(PopUpFont.Color)+';font-family:'+PopUpFont.FontName+';font-size:'+IntToStr(PopUpFont.Size)+';cursor:default;" id="'+ HTMLName +'tbl" cellspacing="0" cellpadding="2" border="'+gborder+'" '+S+'>'#13;

    if ColumnTitles.Visible then
      begin
        backcolor := '';
        forecolor := '';
        style := '';

        if (ColumnTitles.BackColor <> clNone) then
          backcolor := HTMLClr(ColumnTitles.BackColor);

        if (ColumnTitles.Font.Color <> clNone) then
          forecolor := HTMLClr(ColumnTitles.Font.Color);

      style := 'style="color:'+forecolor+';font-size:'+IntToStr(ColumnTitles.Font.Size)+';font-family:'+ColumnTitles.Font.FontName+';"';

      htmlres := htmlres + '<TR bgcolor='+backcolor+' '+style+'>';
        for i:=0 to ColCount-1 do
        begin
          rowtitle := '';
          if ColumnTitles.Titles.Count > i then
            rowTitle := ColumnTitles.Titles[i];
          htmlres := htmlres + '<TD>'+rowtitle+'&nbsp;</TD>';
        end;

        htmlres := htmlres + '</TR>';

      end;


    for r:=0 to FComboRows.Count-1 do
    begin
      rowval := EmptyStr;
      if FComboRows[r].RowData.Count <> 0 then
        rowval := FComboRows[r].RowData[0];

      htmlres := htmlres + '<span id="val'+ HTMLName +'RowNo'+inttostr(r)+'" style="visiblity:hidden;display:none;">'+rowval+'</span>';
      htmlres := htmlres + '<tr id="'+ HTMLName +'RowNo'+inttostr(r)+'" value="'+rowval+'" onmouseup = "'+HTMLName+'ChangeEditValue('''+ HTMLName +'ED'','''+ HTMLName +'RowNo'+inttostr(r) +''')" onmousemove = "CCShowHighLighted('''+ HTMLName +'RowNo'+inttostr(r) +''','+HTMLName+'obj,'+IntToStr(FColCount - 1)+')" onmouseout = "CCShowUnHighLighted('''+ HTMLName +'RowNo'+inttostr(r) +''','+IntToStr(FColCount - 1)+','+HTMLName+'obj)">'#13;

      for c:=0 to FColCount-1 do
      begin
//        htmlres := htmlres + '<td width="'+inttostr(ColWidth)+'">'#13;
        htmlres := htmlres + '<td>'#13;
        if c < FComboRows[r].RowData.Count then
          //htmlres := htmlres + '<font class="'+font.FontVariant+'" '+S+'>' + FComboRows[r].RowData[c] + '&nbsp;</font>'
          htmlres := htmlres + '' + FComboRows[r].RowData[c] + '&nbsp;'
        else
          //htmlres := htmlres + '<font class="'+font.FontVariant+'" '+S+'>&nbsp;</font>';
          htmlres := htmlres + '&nbsp;';
        htmlres := htmlres + '</td>'#13;
      end;
      htmlres := htmlres + '</tr>'#13;
    end;
    htmlres := htmlres + '</table>';
    htmlres := htmlres + '</div>';

    htmlres := htmlres
      + '</div>'#13
  //    + ' </td>'#13
  //    + ' </tr></table>';
   + '';

    MakeCScript;

    {$IFDEF TMSIW6}
    TIWComponent40Context(AContext).AddToJavaScriptOnce(CScript.Text);
    {$ELSE}
    AddToJavaScriptOnce(CScript.Text);
    {$ENDIF}

    FreeAndNil(CScript);

    if SupportsInput and Required then
    begin
      {$IFDEF TMSIW6}
      TIWComponent40Context(AContext).AddValidation('GSubmitter.' + HTMLName + '.value.length==0'
       , FriendlyName + ' is a required field.');
      {$ELSE}
      TIWAppForm(Owner).AddValidation('GSubmitter.' + HTMLName + '.value.length==0'
       , FriendlyName + ' is a required field.');
      {$ENDIF}
    end;

  Result := TIWHTMLTag.CreateTag('DIV');
  Result.Contents.AddText(htmlres);
end;

//------------------------------------------------------------------------------
procedure TTIWMultiColumnComboBox.SetAlignment(const Value: TAlignment);
begin
  FAlignment := Value;
  Invalidate;
end;

//------------------------------------------------------------------------------
procedure TTIWMultiColumnComboBox.SetColCount(const Value: Integer);
begin
  if (Value > 1) then
    FColCount := Value
  else
    FColCount := 1;
  Invalidate;
end;

//------------------------------------------------------------------------------

procedure TTIWMultiColumnComboBox.SetBorderColor(const Value: TColor);
begin
  FBorderColor := Value;
  Invalidate;
end;

//------------------------------------------------------------------------------
procedure TTIWMultiColumnComboBox.SetBorderWidth(const Value: Integer);
begin
  FBorderWidth := Value;
  Invalidate;
end;

//------------------------------------------------------------------------------
procedure TTIWMultiColumnComboBox.SetColor(const Value: TColor);
begin
  FColor := Value;
  Invalidate;
end;

//------------------------------------------------------------------------------
procedure TTIWMultiColumnComboBox.SetFlat(const Value: Boolean);
begin
  FFlat := Value;
  Invalidate;
end;

procedure TTIWMultiColumnComboBox.SetColumnTitles(const Value: TTIWColumnTitles);
begin
  FColumnTitles.Assign(Value);
  Invalidate;
end;

//------------------------------------------------------------------------------
{procedure TTIWColumnComboBox.SetList(const Value: TStringList);
begin
  FList.Assign(Value);
end;
}


{ TTIWColumnTitles }

constructor TTIWColumnTitles.Create;
begin
    FBackColor := clNone;
    FFont := TIWFont.Create;
    FTitles := TStringList.Create;
    FVisible := false;
end;

destructor TTIWColumnTitles.Destroy;
begin
  FFont.Free;
  FTitles.Free;
  inherited;
end;

procedure TTIWColumnTitles.Assign(Source: TPersistent);
begin
  if not (Source is TTIWColumnTitles) then
    raise Exception.Create('Cannot assign Source to TTIWColumnTitles');

  with Source as TTIWColumnTitles do
  begin
    FBackColor := BackColor;
  //  FTitles.Assign(Titles);
    FTitles := Titles;
    FVisible := Visible;
    FFont.Assign(Font);
  end;
end;

procedure TTIWColumnTitles.SetBackColor(const Value: TIWColor);
begin
FBackColor := Value;
end;

procedure TTIWColumnTitles.SetFont(const Value: TIWFont);
begin
FFont := Value
end;


procedure TTIWColumnTitles.SetTitles(const Value: TStrings);
begin
  FTitles.Assign(Value);
end;

procedure TTIWColumnTitles.SetVisible(const Value: boolean);
begin
  FVisible := Value;
end;



end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -