ورود

View Full Version : سوال: چرا بین جعبه متن های درون خانه های جدول فاصله می افته؟!



ROSTAM2
پنج شنبه 25 مرداد 1403, 11:02 صبح
سلام

من یک سند HTML دارم که برای جدول Header ردیفی برای اضافه کردن جعبه متن Input (text) ایجاد کرده ام برای نوشتن مقادیر همه جعبه متن ها خصوصیت width برابر با 92% هست ولی فاصله آنها از جعبه متن بعدی با هم یکسان نیست؟! چطور می شه این مشکل رو رفع کرد.

اگه width 100% بشه همه جعبه متن ها بصورت یک جعبه متن در امتداد ردیف جدول نمایش داده می شه....

155967


Sub AddFieldsRow(ParamArray Cells() As Field)
Dim TR As mshtml.HTMLTableRow, TD As mshtml.HTMLTableCell
With Me.WebBrowser2.Document
TR = .CreateElement("tr").DomElement
TD = .CreateElement("td").DomElement
TD.id = "Row"
TD.innerText = ""
TD.style.width = "60px"
TD.style.color = "White"
TR.appendChild(TD)
'--------------------
For Each Cell As Field In Cells
Dim Box As mshtml.HTMLInputElement = .CreateElement("input").DomElement
TD = .CreateElement("td").DomElement
With TD.style


End With
Box.type = "text"
Box.id = Cell.ID
Box.align = "center"
If (Cell.LeftToRight) Then Box.dir = "ltr"
Box.setAttribute("placeholder", Cell.Text)
If Cell.MaxLength > 0 Then
Box.maxLength = Cell.MaxLength
End If
With Box.style
.width = "92%"
.textAlign = "center"
End With


TD.appendChild(Box)
TR.appendChild(TD)
Next
'--------------------
Dim AddButton As mshtml.HTMLImg = .CreateElement("img").DomElement
With AddButton
.id = "addItem"
With .style
.margin = "1px"
.cursor = "pointer"
.verticalAlign = "middle"
.styleFloat = "right"
End With
.setAttribute("src", Base64StringJpegData("add.png"))
.width = 32
.height = 32
End With
Dim CancelButton As mshtml.HTMLImg = .CreateElement("img").DomElement
With CancelButton
.id = "discardItem"
With .style
.margin = "1px"
.cursor = "pointer"
.verticalAlign = "middle"
.styleFloat = "right"
End With
.setAttribute("src", Base64StringJpegData("cancel.png"))
.width = 32
.height = 32
End With
Dim AcceptButton As mshtml.HTMLImg = .CreateElement("img").DomElement
With AcceptButton
.id = "updateItem"
With .style
.margin = "1px"
.cursor = "pointer"
.verticalAlign = "middle"
.styleFloat = "right"
End With
.setAttribute("src", Base64StringJpegData("accept.png"))
.width = 32
.height = 32
End With
TD = .CreateElement("td").DomElement
With TD.style
.whiteSpace = "nowrap"
.verticalAlign = "middle"
End With
TD.appendChild(AddButton)
TD.appendChild(AcceptButton)
TD.appendChild(CancelButton)
TD.width = 120


'TD.style.width = "150px"
TR.appendChild(TD)


Dim TableRow As HtmlElement = .CreateElement("tr")
With TableRow
.InnerHtml = TR.innerHTML
.Style = "text-Align: Center;"


End With
FieldsTable = .GetElementById("FieldsTable")
FieldsTable.AppendChild(TableRow)
AddItemButton = .GetElementById("addItem")
UpdateItemButton = .GetElementById("updateItem")
DiscardItemButton = .GetElementById("discardItem")
UpdateItemButton.SetVisiblity(False)
DiscardItemButton.SetVisiblity(False)
End With


End Sub

ROSTAM2
پنج شنبه 25 مرداد 1403, 11:12 صبح
در این نمونه width 100% شده و marginleft و marginright = 2px شده ولی باز هم بصورت یک جعبه متن نمایش داده می شه!!!

155968


With Box.style
.width = "100%"
.textAlign = "center"
.marginLeft = "2px"
.marginRight = "2px"
End With

ROSTAM2
پنج شنبه 25 مرداد 1403, 11:18 صبح
دستتون درد نکنه الآن درست شد: PaddingLeft و paddingright از خانه های ردیف جدول رو 5px کردم....


With TD.style
.paddingLeft = "5px"
.paddingRight = "5px"
End With


155969