1

Konu: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

arkadaslar bir tablomvar tablomda iki kolon var ID ve text ben combomu bu tabloya bagladim. bir deger sectigi zaman combonun ustune yazi degerini yazacagina ID yi yaziyor. bunu nasil hallederim acaba

kullandigim kod

WITH THis
.RowSourceType = 3
.RowSource = "select id,takiptipi from takiptipleri into cursor localtakiptiplericursor"
.ColumnCount = 2
.ListIndex = 2
.Style = 2
ENDWITH

zannedersem .value ile defaultta istedigim elemani secebilirim form ilk acildiginda yani. ama birsey sectigimde yazi yerine ID sinin comboya yazili gorunmesini engelleyemedim

bir fikri olan varsa sevinirim

2

Re: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

Comboda daima ilk sutun gosterilir. Siralarini takiptipi,id olarak degistir.

3

Re: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

ama abi bir item secildigi zamanda o yaziyi degilde o yazi ile iliskili ID yi ele gecirip db ye onu yazmam gerekiyor
uzerinde ugrasiyorum

4

Re: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

evet ters cevirdim text ilk kolon oldu ID ikinci kolon
comboya sag tusla tiklayip builderdan kolonlari yerlestirdim value kismina ID yi girdim

.text diyince texti veriyor
.value diyince id yi

aslinda cok basitmis

5

Re: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

.Text ozel. Ona pek dokunma (ne oldugunu tam anlayana kadar).
Gosterilen deger lazimsa:
.DisplayValue

O anki deger lazimsa .Value

Herhangi bir kolondaki deger lazimsa:
with thisform.myCombo
  lcValue = .List(.ListIndex, kolonNosu)
endwith

RowSourceType = 3 (ya da sonucu tale/cursor olan baska birsey ise - ki benim favorim 3)
oldugunda isler daha kolay. Sadece 1-2 kolon gosterip, aslinda RowSource'da olan herhangi bir kolona dogrudan ulasirsin. Ustelik combodan value, list() gibi yontemlerle aldigin degerler hep karakter iken, bu yontemde gercek datatipleriyle erisirsin, sana lazim olan id kolonu eger sayisal bir deger ise VFP'nin ilk versiyonundan beri duzeltmemekte israr ettikleri bugla da ugrasmazsin (hata eger o integer ise ve boundto = .t. degil ise, value sana ID degil ListIndex dondurur - neden bug olarak kabul etmediklerini hic anlamadim).


Visual Fox Pro
Public oForm

oForm = Createobject('comboOrnek')
oForm.Show
 
Define Class ComboOrnek As Form
  DataSession = 2
  Add Object cmbOrnek As ComboBox With Top = 10,Left = 10, Width = 200
  Add Object btnGoster As CommandButton With Top = 10,Left = 210, Caption = 'Goster'
  Add Object txt1 As TextBox With Top = 50,Left = 10, Width = 200
  Add Object txt2 As TextBox With Top = 80,Left = 10, Width = 200
  Add Object txt3 As TextBox With Top = 110,Left = 10, Width = 200
  Add Object txt4 As TextBox With Top = 140,Left = 10, Width = 200
  Add Object txt5 As TextBox With Top = 170,Left = 10, Width = 200
  Add Object txt6 As TextBox With Top = 200,Left = 10, Width = 200
  Add Object txt7 As TextBox With Top = 200,Left = 210, Width = 20
  Add Object txt8 As TextBox With Top = 230,Left = 10, Width = 200
  Add Object txt9 As TextBox With Top = 230,Left = 210, Width = 20
 
  Procedure cmbOrnek.Init
    With This
      .RowSourceType = 3
      TEXT TO .RowSource NOSHOW PRETEXT 15
select
    first_Name-(' '+Last_Name-(":["+order_id+"]")) as empOrder,
    employee.emp_id as myId,
    orders.*
from (_samples+'data\employee') employee
   INNER JOIN (_samples+'data\orders') orders
     ON employee.emp_id == orders.emp_id
ORDER BY 1
into cursor xx nofilter
      ENDTEXT
      .ColumnCount = 1
      .BoundColumn = 2
    Endwith
  Endproc
 
  Procedure cmbOrnek.InteractiveChange
    With Thisform
      .txt1.Value = This.Text
      .txt2.Value = This.Value
      .txt3.Value = This.DisplayValue
      .txt4.Value = This.ListIndex
      .txt5.Value = xx.myId
      .txt6.Value = xx.order_date
      .txt7.Value = Type('xx.order_date') && data tipi date
      Local Array aFieldList[1]
      Local lnOrderDateCol,luValue
      Afields(aFieldList,'xx')
      lnOrderDateCol = Ascan(aFieldList,'order_date',1,-1,1,1+2+4+8)
      luValue = This.List(This.ListIndex, m.lnOrderDateCol)
      .txt8.Value = m.luValue
      .txt9.Value = Type('m.luValue') && data tipi char
    Endwith
  Endproc
 
  Procedure btnGoster.Click
    Cursortoxml('xx','lcXML',1,2,1)
    Messagebox("Secilen kayit:"+Chr(13)+m.lcXML)
  Endproc
Enddefine

6

Re: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

simdi combobox umu elimle init ediyorum, comboboxumun init metodunda asagidaki gibi

WITH THis
.RowSourceType = 3
.RowSource = "select takiptipi,id from takiptipleri into cursor localtakiptiplericursor"
.ColumnCount = 1
.ListIndex = 1
.Style = 2
ENDWITH


sonrada degerlere ulasmak icin asagidaki kodu kullaniyorum

txt= thisform.cmbTakipTipi.DisplayValue
takiptipi = thisform.cmbtakiptipi.List(thisform.cmbtakiptipi.ListIndex,2)

MESSAGEBOX(takiptipi)
MESSAGEBOX(txt)

fakat takiptipi ve txt ikiside takiptipi kolonundan geliyor. takiptipi kolonu aslinda birinci kolon
ayrica txt icine o anki secili takiptipi gelirken
takiptipi icine select ile donen butun takiptiplerinden birincisi geliyor

boyle sacma sapan bir sey gormedim. cok ilginc

7 Son düzenleyen, cetinbasoz (24.05.2008 10:23:39)

Re: combobox i bir tablodan doldurup belirli bir ID yi secili gostermek

Hafiza degiskenlerinin basina m. koy diye kac kere soylemem lazim:)