unsafe public void Create() { xc.XInitXCGUI(""); int hWindow = XWnd.Create(0, 0, 500, 400, "xcgui", 0, 15); hListBox = XListBox.Create(0, 0, 300, 300, hWindow); XListBox.SetItemTemplateXML(hListBox, "..\\..\\ListBox_Item.xml"); int hAdapter = XAdapterTable.Create(); XListBox.BindAdapter(hListBox, hAdapter); XAdapterTable.AddColumn(hAdapter, "name"); XAdapterTable.AddColumn(hAdapter, "name1"); int nItem = XAdapterTable.AddItemText(hAdapter, "dasemimi"); XAdapterTable.SetItemText(hAdapter, nItem, 1, "xiaosemimi"); nItem = XAdapterTable.AddItemText(hAdapter, "dasemimi1"); XAdapterTable.SetItemText(hAdapter, nItem, 1, "xiaosemimi1"); XEle.RegEventCPP(hListBox, xcConst.XE_LISTBOX_TEMP_CREATE_END, new XE_LISTBOX_TEMP_CREATE_END_CPP(__OnListBoxTemplateCreateEnd)); XWnd.ShowWindow(hWindow, 5); xc.XRunXCGUI(); xc.XExitXCGUI(); }
private void RenderListBox(XListBox listBox) { var result = new FrameView() { Title = listBox.Title, X = Pos.Left(this) + listBox.Left + _left, }; var list = new ListView { Width = Dim.Fill(), Height = Dim.Fill(), }; list.SelectedItemChanged += List_SelectedItemChanged; if (Binder.IsBindable(listBox.ItemSourceProperty)) { list.SetSource(_binder.GetList(listBox.ItemSourceProperty)); } if (Binder.IsBindable(listBox.SelectedIndex)) { list.SelectedItem = Convert.ToInt32(_binder.GetBindedText(listBox.SelectedIndex)); _binder.Register(listBox, list, typeof(int)); } result.Add(list); result.Height = Dim.Fill(); UiPage.SetWidth(result, listBox); Add(result); _left += Pos.Right(result); }
unsafe private int __OnBtnClick(int hEventEle, bool *pbHandled) { //获取当前点击的按钮所在列表项索引 int nId = XListBox.GetItemIndexFromHXCGUI(hListBox, hEventEle); //int nId = xc.XEle_GetTemplateListItemID(hEventEle); return(0); }
unsafe private int __OnListBoxTemplateCreateEnd(ref listBox_item_i pItem, bool *pbHandled) { int hBtn = XListBox.GetTemplateObject(hListBox, pItem.index, 2); if (xc.IsHXCGUI(hBtn, xcConst.XC_BUTTON)) { XEle.RegEventCPP1(hBtn, xcConst.XE_BNCLICK, new XE_BNCLICK_CPP1(__OnBtnClick)); } return(0); }
public PastTreeView() { InitializeComponent(); this.xListBox = new XListBox(this); this.xListBox.FrameBrush = new SolidBrush(Color.FromArgb(232, 232, 232)); this.xListBox.Size = new Size(248, 250); this.xListBox.Location = new Point(0, 0); this.AddRender(this.xListBox); this.xListBox.SelectedValueChanged += new EventHandler(xListBox_SelectedValueChanged); this.Load += new EventHandler(PastTreeView_Load); this.Resize += new EventHandler(PastTreeView_Resize); }