# DComboBox

- **Ortam:** İstemci, Menü
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/DComboBox
- **Çeviri tarihi:** 2025-09-08

## Açıklama

Birden fazla seçilebilir değere sahip bir alan.

[Kaynağı görüntüle](https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dcombobox.lua)

## Ebeveyn

Bu sayfada listelenmeyen metotları vb. [DButton](https://gmod.tr/wiki/DButton)'dan alır.

## Uygular

Aşağıdaki kancaları/metotları uygular veya geçersiz kılar. Bunları geçersiz kılmak istiyorsanız, muhtemelen orijinal fonksiyonu da çağırmak istersiniz.

- [Panel:Init](https://gmod.tr/wiki/PANEL:Init)
- [Panel:Clear](https://gmod.tr/wiki/Panel:Clear)
- [Panel:Think](https://gmod.tr/wiki/PANEL:Think)
- [Panel:PerformLayout](https://gmod.tr/wiki/PANEL:PerformLayout)
- [Panel:GenerateExample](https://gmod.tr/wiki/PANEL:GenerateExample)
- [DLabel:DoClick](https://gmod.tr/wiki/DLabel:DoClick)

## Olaylar

DComboBox:[OnMenuOpened](https://gmod.tr/wiki/DComboBox:OnMenuOpened)( [Panel](https://gmod.tr/wiki/Panel) menu )

Oyuncu açılır menüyü açtığında çağrılır. Geçersiz kılmak içindir (For Override).

DComboBox:[OnSelect](https://gmod.tr/wiki/DComboBox:OnSelect)( [number](https://gmod.tr/wiki/number) index, [string](https://gmod.tr/wiki/string) value, [any](https://gmod.tr/wiki/any) data )

Açılır kutudaki bir seçenek seçildiğinde çağrılır. Bu fonksiyon tek başına bir şey yapmaz, üzerine yazmanız beklenir.

## Metotlar

[number](https://gmod.tr/wiki/number) DComboBox:[AddChoice](https://gmod.tr/wiki/DComboBox:AddChoice)( [string](https://gmod.tr/wiki/string) value, [any](https://gmod.tr/wiki/any) data = nil, [boolean](https://gmod.tr/wiki/boolean) select = false, [string](https://gmod.tr/wiki/string) icon = nil )

Açılır kutuya bir seçenek ekler.

DComboBox:[AddSpacer](https://gmod.tr/wiki/DComboBox:AddSpacer)()

Açılır menüdeki mevcut son öğenin altına bir ayırıcı ekler. DComboBox:SetSortItems'ın false olarak ayarlanmasıyla kullanılması önerilir.

DComboBox:[CheckConVarChanges](https://gmod.tr/wiki/DComboBox:CheckConVarChanges)()

Bu dahili olarak kullanılır - kullanabiliyor olsanız da muhtemelen kullanmamalısınız. Bu panelin değerini ilişkili convar'ın değeriyle güncellemek için her karede çalıştırılır. Bakınız Panel:SetConvar.

DComboBox:[ChooseOption](https://gmod.tr/wiki/DComboBox:ChooseOption)( [string](https://gmod.tr/wiki/string) value, [number](https://gmod.tr/wiki/number) index )

Dizinine göre bir açılır kutu seçeneğini seçer ve açılır kutunun üstünde görüntülenen metni değiştirir.

DComboBox:[ChooseOptionID](https://gmod.tr/wiki/DComboBox:ChooseOptionID)( [number](https://gmod.tr/wiki/number) index )

Tablo dizinine göre bir açılır kutu içindeki bir seçeneği seçer.

DComboBox:[Clear](https://gmod.tr/wiki/DComboBox:Clear)()

Açılır kutunun metin değerini, seçimlerini ve veri değerlerini temizler.

DComboBox:[CloseMenu](https://gmod.tr/wiki/DComboBox:CloseMenu)()

Açılır kutu menüsünü kapatır. Açılır kutu açıkken tıklandığında çağrılır.

[any](https://gmod.tr/wiki/any) DComboBox:[GetOptionData](https://gmod.tr/wiki/DComboBox:GetOptionData)( [number](https://gmod.tr/wiki/number) index )

Verilen dizine göre bir seçeneğin verisini döndürür.

[string](https://gmod.tr/wiki/string) DComboBox:[GetOptionText](https://gmod.tr/wiki/DComboBox:GetOptionText)( [number](https://gmod.tr/wiki/number) index )

Verilen dizine göre bir seçeneğin metnini döndürür.

[string](https://gmod.tr/wiki/string) DComboBox:[GetOptionTextByData](https://gmod.tr/wiki/DComboBox:GetOptionTextByData)( [string](https://gmod.tr/wiki/string) data )

Verilen veriye göre bir seçeneğin metnini döndürür.

[string](https://gmod.tr/wiki/string), [any](https://gmod.tr/wiki/any) DComboBox:[GetSelected](https://gmod.tr/wiki/DComboBox:GetSelected)()

Mevcut seçili seçeneğin metnini ve verisini döndürür

[number](https://gmod.tr/wiki/number) DComboBox:[GetSelectedID](https://gmod.tr/wiki/DComboBox:GetSelectedID)()

Mevcut seçili seçeneğin dizinini (ID) döndürür.

[boolean](https://gmod.tr/wiki/boolean) DComboBox:[GetSortItems](https://gmod.tr/wiki/DComboBox:GetSortItems)()

Açılır menüdeki öğelerin alfabetik olarak sıralanıp sıralanmayacağını döndüren bir AccessorFunc'tır. Bakınız DComboBox:SetSortItems.

[boolean](https://gmod.tr/wiki/boolean) DComboBox:[IsMenuOpen](https://gmod.tr/wiki/DComboBox:IsMenuOpen)()

Açılır kutunun menüsünün açık olup olmadığını döndürür.

DComboBox:[OpenMenu](https://gmod.tr/wiki/DComboBox:OpenMenu)()

Açılır kutu menüsünü açar. Açılır kutuya tıklandığında çağrılır.

[string](https://gmod.tr/wiki/string), [any](https://gmod.tr/wiki/any) DComboBox:[RemoveChoice](https://gmod.tr/wiki/DComboBox:RemoveChoice)( [number](https://gmod.tr/wiki/number) index )

DComboBox:AddChoice ile eklenen bir seçimi kaldırır

DComboBox:[SetSortItems](https://gmod.tr/wiki/DComboBox:SetSortItems)( [boolean](https://gmod.tr/wiki/boolean) sort )

Öğelerin DComboBox'ın açılır menüsünde alfabetik olarak sıralanıp sıralanmayacağını ayarlayan bir AccessorFunc'tır. False olarak ayarlanırsa, öğeler DComboBox:AddChoice çağrılarıyla eklendikleri sırayla görünürler. Bu varsayılan olarak etkindir.

DComboBox:[SetValue](https://gmod.tr/wiki/DComboBox:SetValue)( [string](https://gmod.tr/wiki/string) value )

Menü daraltılmadığında açılır kutuda gösterilen metni ayarlar.

### Örnek

Bir Açılır Kutu (Combo Box) oluşturur.

```lua
local frame = vgui.Create( "DFrame" )
frame:SetSize( 300, 250 )
frame:Center()
frame:MakePopup()

local DComboBox = vgui.Create( "DComboBox", frame )
DComboBox:SetPos( 5, 30 )
DComboBox:SetSize( 100, 20 )
DComboBox:SetValue( "options" )
DComboBox:AddChoice( "option A" )
DComboBox:AddChoice( "option B" )
DComboBox:AddChoice( "option C" )
DComboBox.OnSelect = function( self, index, value )
	print( value .. " was selected at index " .. index )
end
```

**Çıktı:** ![](https://gmod.tr/api/uploads/wiki/2cf01fca124bf2bc859f.png) ![](https://gmod.tr/api/uploads/wiki/84c471d336afb26b3479.png) ![](https://gmod.tr/api/uploads/wiki/19b6fc3a17440d8bec61.png)

```lua
option B was selected at index 2
```

### Örnek

Tüm oyuncularla bir Açılır Kutu (Combo Box) oluşturur.

```lua
local comboBox = vgui.Create( "DComboBox" )
comboBox:SetPos( 5, 5 )
comboBox:SetSize( 100, 20 )
comboBox:SetValue( "All Players" )

comboBox.OnSelect = function( _, _, value )
	print( value .. " was selected!" )
end

for _, v in ipairs( player.GetAll() ) do
	comboBox:AddChoice( v:Name() )
end
```

`derma_controls` concmd'sinden önizleme

![DComboBox.gif](https://gmod.tr/api/uploads/wiki/7830428e478e7ac47a8a.gif)

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/DComboBox
