เรียนรู้
Engine Class
UITableLayout

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
สมาชิกที่ได้รับทอด
ตัวอย่างโค้ด
สร้างตาราง UI
local frame = script.Parent
-- ข้อมูลตาราง
local headerWidth = { 200, 80, 80 }
local headers = {
"ชื่อ",
"งาน",
"เงินสด",
}
local data = {
{ "บ็อบ", "พนักงานเสิร์ฟ", 100 },
{ "ลิซ่า", "ตำรวจ", 200 },
{ "จอร์จ", "-", 50 },
}
-- ก่อนอื่น สร้างเลเอาต์ตาราง
local uiTableLayout = Instance.new("UITableLayout")
uiTableLayout.FillDirection = Enum.FillDirection.Vertical
uiTableLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
uiTableLayout.VerticalAlignment = Enum.VerticalAlignment.Center
uiTableLayout.FillEmptySpaceColumns = false
uiTableLayout.FillEmptySpaceRows = false
uiTableLayout.Padding = UDim2.new(0, 5, 0, 5)
uiTableLayout.SortOrder = Enum.SortOrder.LayoutOrder
frame.Size = UDim2.new(0, 0, 0, 40) -- ขนาดของเฟรมหลักคือขนาดเซลล์
uiTableLayout.Parent = frame
-- ต่อไป สร้างหัวข้อคอลัมน์
local headerFrame = Instance.new("Frame")
headerFrame.Name = "Headers"
headerFrame.Parent = frame
for i = 1, #headers do
local headerText = headers[i]
local headerCell = Instance.new("TextLabel")
headerCell.Text = headerText
headerCell.Name = headerText
headerCell.LayoutOrder = i
headerCell.Size = UDim2.new(0, 0, 0, 24)
headerCell.Parent = headerFrame
local headerSize = Instance.new("UISizeConstraint")
headerSize.MinSize = Vector2.new(headerWidth[i], 0)
headerSize.Parent = headerCell
end
-- สุดท้าย เพิ่มแถวข้อมูลโดยการวนซ้ำผ่านแต่ละแถวและคอลัมน์ในแถวที่นั้น
for index, value in ipairs(data) do
local rowData = value
local rowFrame = Instance.new("Frame")
rowFrame.Name = "Row" .. index
rowFrame.Parent = frame
for col = 1, #value do
local cellData = rowData[col]
local cell = Instance.new("TextLabel")
cell.Text = cellData
cell.Name = headers[col]
cell.TextXAlignment = Enum.TextXAlignment.Left
if tonumber(cellData) then -- ถ้าเซลล์นี้เป็นตัวเลข ให้จัดเรียงด้านขวาแทน
cell.TextXAlignment = Enum.TextXAlignment.Right
end
cell.ClipsDescendants = true
cell.Size = UDim2.new(0, 0, 0, 24)
cell.Parent = rowFrame
end
end

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
FillEmptySpaceColumns
อ่านพร้อมๆ กัน
ความสามารถ: UI
UITableLayout.FillEmptySpaceColumns:boolean
ตัวอย่างโค้ด
สร้างตาราง UI
local frame = script.Parent
-- ข้อมูลตาราง
local headerWidth = { 200, 80, 80 }
local headers = {
"ชื่อ",
"งาน",
"เงินสด",
}
local data = {
{ "บ็อบ", "พนักงานเสิร์ฟ", 100 },
{ "ลิซ่า", "ตำรวจ", 200 },
{ "จอร์จ", "-", 50 },
}
-- ก่อนอื่น สร้างเลเอาต์ตาราง
local uiTableLayout = Instance.new("UITableLayout")
uiTableLayout.FillDirection = Enum.FillDirection.Vertical
uiTableLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
uiTableLayout.VerticalAlignment = Enum.VerticalAlignment.Center
uiTableLayout.FillEmptySpaceColumns = false
uiTableLayout.FillEmptySpaceRows = false
uiTableLayout.Padding = UDim2.new(0, 5, 0, 5)
uiTableLayout.SortOrder = Enum.SortOrder.LayoutOrder
frame.Size = UDim2.new(0, 0, 0, 40) -- ขนาดของเฟรมหลักคือขนาดเซลล์
uiTableLayout.Parent = frame
-- ต่อไป สร้างหัวข้อคอลัมน์
local headerFrame = Instance.new("Frame")
headerFrame.Name = "Headers"
headerFrame.Parent = frame
for i = 1, #headers do
local headerText = headers[i]
local headerCell = Instance.new("TextLabel")
headerCell.Text = headerText
headerCell.Name = headerText
headerCell.LayoutOrder = i
headerCell.Size = UDim2.new(0, 0, 0, 24)
headerCell.Parent = headerFrame
local headerSize = Instance.new("UISizeConstraint")
headerSize.MinSize = Vector2.new(headerWidth[i], 0)
headerSize.Parent = headerCell
end
-- สุดท้าย เพิ่มแถวข้อมูลโดยการวนซ้ำผ่านแต่ละแถวและคอลัมน์ในแถวที่นั้น
for index, value in ipairs(data) do
local rowData = value
local rowFrame = Instance.new("Frame")
rowFrame.Name = "Row" .. index
rowFrame.Parent = frame
for col = 1, #value do
local cellData = rowData[col]
local cell = Instance.new("TextLabel")
cell.Text = cellData
cell.Name = headers[col]
cell.TextXAlignment = Enum.TextXAlignment.Left
if tonumber(cellData) then -- ถ้าเซลล์นี้เป็นตัวเลข ให้จัดเรียงด้านขวาแทน
cell.TextXAlignment = Enum.TextXAlignment.Right
end
cell.ClipsDescendants = true
cell.Size = UDim2.new(0, 0, 0, 24)
cell.Parent = rowFrame
end
end

FillEmptySpaceRows
อ่านพร้อมๆ กัน
ความสามารถ: UI
UITableLayout.FillEmptySpaceRows:boolean
ตัวอย่างโค้ด
สร้างตาราง UI
local frame = script.Parent
-- ข้อมูลตาราง
local headerWidth = { 200, 80, 80 }
local headers = {
"ชื่อ",
"งาน",
"เงินสด",
}
local data = {
{ "บ็อบ", "พนักงานเสิร์ฟ", 100 },
{ "ลิซ่า", "ตำรวจ", 200 },
{ "จอร์จ", "-", 50 },
}
-- ก่อนอื่น สร้างเลเอาต์ตาราง
local uiTableLayout = Instance.new("UITableLayout")
uiTableLayout.FillDirection = Enum.FillDirection.Vertical
uiTableLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
uiTableLayout.VerticalAlignment = Enum.VerticalAlignment.Center
uiTableLayout.FillEmptySpaceColumns = false
uiTableLayout.FillEmptySpaceRows = false
uiTableLayout.Padding = UDim2.new(0, 5, 0, 5)
uiTableLayout.SortOrder = Enum.SortOrder.LayoutOrder
frame.Size = UDim2.new(0, 0, 0, 40) -- ขนาดของเฟรมหลักคือขนาดเซลล์
uiTableLayout.Parent = frame
-- ต่อไป สร้างหัวข้อคอลัมน์
local headerFrame = Instance.new("Frame")
headerFrame.Name = "Headers"
headerFrame.Parent = frame
for i = 1, #headers do
local headerText = headers[i]
local headerCell = Instance.new("TextLabel")
headerCell.Text = headerText
headerCell.Name = headerText
headerCell.LayoutOrder = i
headerCell.Size = UDim2.new(0, 0, 0, 24)
headerCell.Parent = headerFrame
local headerSize = Instance.new("UISizeConstraint")
headerSize.MinSize = Vector2.new(headerWidth[i], 0)
headerSize.Parent = headerCell
end
-- สุดท้าย เพิ่มแถวข้อมูลโดยการวนซ้ำผ่านแต่ละแถวและคอลัมน์ในแถวที่นั้น
for index, value in ipairs(data) do
local rowData = value
local rowFrame = Instance.new("Frame")
rowFrame.Name = "Row" .. index
rowFrame.Parent = frame
for col = 1, #value do
local cellData = rowData[col]
local cell = Instance.new("TextLabel")
cell.Text = cellData
cell.Name = headers[col]
cell.TextXAlignment = Enum.TextXAlignment.Left
if tonumber(cellData) then -- ถ้าเซลล์นี้เป็นตัวเลข ให้จัดเรียงด้านขวาแทน
cell.TextXAlignment = Enum.TextXAlignment.Right
end
cell.ClipsDescendants = true
cell.Size = UDim2.new(0, 0, 0, 24)
cell.Parent = rowFrame
end
end

MajorAxis
อ่านพร้อมๆ กัน
ความสามารถ: UI
UITableLayout.MajorAxis:Enum.TableMajorAxis
ตัวอย่างโค้ด
สร้างตาราง UI
local frame = script.Parent
-- ข้อมูลตาราง
local headerWidth = { 200, 80, 80 }
local headers = {
"ชื่อ",
"งาน",
"เงินสด",
}
local data = {
{ "บ็อบ", "พนักงานเสิร์ฟ", 100 },
{ "ลิซ่า", "ตำรวจ", 200 },
{ "จอร์จ", "-", 50 },
}
-- ก่อนอื่น สร้างเลเอาต์ตาราง
local uiTableLayout = Instance.new("UITableLayout")
uiTableLayout.FillDirection = Enum.FillDirection.Vertical
uiTableLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
uiTableLayout.VerticalAlignment = Enum.VerticalAlignment.Center
uiTableLayout.FillEmptySpaceColumns = false
uiTableLayout.FillEmptySpaceRows = false
uiTableLayout.Padding = UDim2.new(0, 5, 0, 5)
uiTableLayout.SortOrder = Enum.SortOrder.LayoutOrder
frame.Size = UDim2.new(0, 0, 0, 40) -- ขนาดของเฟรมหลักคือขนาดเซลล์
uiTableLayout.Parent = frame
-- ต่อไป สร้างหัวข้อคอลัมน์
local headerFrame = Instance.new("Frame")
headerFrame.Name = "Headers"
headerFrame.Parent = frame
for i = 1, #headers do
local headerText = headers[i]
local headerCell = Instance.new("TextLabel")
headerCell.Text = headerText
headerCell.Name = headerText
headerCell.LayoutOrder = i
headerCell.Size = UDim2.new(0, 0, 0, 24)
headerCell.Parent = headerFrame
local headerSize = Instance.new("UISizeConstraint")
headerSize.MinSize = Vector2.new(headerWidth[i], 0)
headerSize.Parent = headerCell
end
-- สุดท้าย เพิ่มแถวข้อมูลโดยการวนซ้ำผ่านแต่ละแถวและคอลัมน์ในแถวที่นั้น
for index, value in ipairs(data) do
local rowData = value
local rowFrame = Instance.new("Frame")
rowFrame.Name = "Row" .. index
rowFrame.Parent = frame
for col = 1, #value do
local cellData = rowData[col]
local cell = Instance.new("TextLabel")
cell.Text = cellData
cell.Name = headers[col]
cell.TextXAlignment = Enum.TextXAlignment.Left
if tonumber(cellData) then -- ถ้าเซลล์นี้เป็นตัวเลข ให้จัดเรียงด้านขวาแทน
cell.TextXAlignment = Enum.TextXAlignment.Right
end
cell.ClipsDescendants = true
cell.Size = UDim2.new(0, 0, 0, 24)
cell.Parent = rowFrame
end
end

Padding
อ่านพร้อมๆ กัน
ความสามารถ: UI
UITableLayout.Padding:UDim2
ตัวอย่างโค้ด
สร้างตาราง UI
local frame = script.Parent
-- ข้อมูลตาราง
local headerWidth = { 200, 80, 80 }
local headers = {
"ชื่อ",
"งาน",
"เงินสด",
}
local data = {
{ "บ็อบ", "พนักงานเสิร์ฟ", 100 },
{ "ลิซ่า", "ตำรวจ", 200 },
{ "จอร์จ", "-", 50 },
}
-- ก่อนอื่น สร้างเลเอาต์ตาราง
local uiTableLayout = Instance.new("UITableLayout")
uiTableLayout.FillDirection = Enum.FillDirection.Vertical
uiTableLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
uiTableLayout.VerticalAlignment = Enum.VerticalAlignment.Center
uiTableLayout.FillEmptySpaceColumns = false
uiTableLayout.FillEmptySpaceRows = false
uiTableLayout.Padding = UDim2.new(0, 5, 0, 5)
uiTableLayout.SortOrder = Enum.SortOrder.LayoutOrder
frame.Size = UDim2.new(0, 0, 0, 40) -- ขนาดของเฟรมหลักคือขนาดเซลล์
uiTableLayout.Parent = frame
-- ต่อไป สร้างหัวข้อคอลัมน์
local headerFrame = Instance.new("Frame")
headerFrame.Name = "Headers"
headerFrame.Parent = frame
for i = 1, #headers do
local headerText = headers[i]
local headerCell = Instance.new("TextLabel")
headerCell.Text = headerText
headerCell.Name = headerText
headerCell.LayoutOrder = i
headerCell.Size = UDim2.new(0, 0, 0, 24)
headerCell.Parent = headerFrame
local headerSize = Instance.new("UISizeConstraint")
headerSize.MinSize = Vector2.new(headerWidth[i], 0)
headerSize.Parent = headerCell
end
-- สุดท้าย เพิ่มแถวข้อมูลโดยการวนซ้ำผ่านแต่ละแถวและคอลัมน์ในแถวที่นั้น
for index, value in ipairs(data) do
local rowData = value
local rowFrame = Instance.new("Frame")
rowFrame.Name = "Row" .. index
rowFrame.Parent = frame
for col = 1, #value do
local cellData = rowData[col]
local cell = Instance.new("TextLabel")
cell.Text = cellData
cell.Name = headers[col]
cell.TextXAlignment = Enum.TextXAlignment.Left
if tonumber(cellData) then -- ถ้าเซลล์นี้เป็นตัวเลข ให้จัดเรียงด้านขวาแทน
cell.TextXAlignment = Enum.TextXAlignment.Right
end
cell.ClipsDescendants = true
cell.Size = UDim2.new(0, 0, 0, 24)
cell.Parent = rowFrame
end
end

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ