First on the map
#region Select city///<summary>///Click Letter Events///</summary>//<param name= "Sender" & gt;</param>//<param name= "E" ></param> void Item_click (object sender, EventArgs e) {LinkLabel LBL = sender as LinkLabel; LbL. Font = new Font (new FontFamily ("Arial"), ten, fontstyle.bold); foreach (Control item in Pan_citytitle.controls) {if (item is LinkLabel && item! = LBL) Item. Font = new Font (new FontFamily ("Arial"), ten, fontstyle.regular); } flowLayoutPanel.Controls.Clear (); Creatcheckcitycontrol (LBL. Tag! = null? LbL. Tag.tostring (): String. Empty); }///<summary>//Draw City Controls///</summary> private void Creatcheckcitycontro L (String lettey) {if (Lettey = = string. Empty) {list<flycity> List = diclist["RM"]; Creatcontrol (list); } else {for (int i = 0; i < Lettey. Length; i++) {String temp = Lettey. Substring (i, 1); if (!diclist.keys.contains (temp)) {continue; } list<flycity> List = Diclist[temp]; Creatcontrol (list); }}} private void Creatcontrol (List<flycity> List) {foreach (flycity fl Y in list) {button Button = new Button () {Text = fly. CityName, Tag = fly, Width =, Height = 25, ForeColor = Color.FromArgb (In the ","), FlatStyle = FlatStyle.Flat,}; button. Flatappearance.bordercolor = Color.White; button. Click + = new EventHandler (Button_Click); button. MouseHover + = new EventHandler (button_mousehover); button. MouseLeave + = new EventHandler (button_mouseleave); FLOWLAYOUTPANEL.CONTROLS.ADD (button); }}///<summary>///Hide control///</summary>//<param name= "Sender" >&L t;/param>//<param name= "E" ></param> void Flyreserveform_mouseup (object sender, Mouseeventa RGS e) {if (!pan_city.capture) {this.pan_City.Visible = false; } if (!calendar. Capture) {this.calendar.Hide (); }}///<summary>///Click to select a destination///</summary>//<param name= "Sender" ;</param>//<param name= "E" ></param> void Btntocity_click (object sender, EventArgs e) {stype = 1; Pan_city.visible = true; Pan_city.location = new Point (446, 100); }//<summary>///Select Departure city///</summary>//<param name= "Sender" ></pa ram>//<param name= "E" ></param> void Btnfromcity_click (object sender, EventArgs e) { stype = 0; Pan_city.visible = true; Pan_city.location = new Point (133, 100); }///<summary>///Get city list from XML///</summary> private void Loadcityarray () {list<flycity> List = new list<flycity> (); Xmlhelper help = new Xmlhelper (environment.currentdirectory + "\\arrays.xml"); DataSet ds = Help. GetData ("Resources"); foreach (DataRow item in DS. Tables[0]. Rows) {flycity fly = new Flycity (); String city = Item[0]. ToString (). Substring (0, item[0]. ToString (). IndexOf (",")); StrinG Citycode = item[0]. ToString (). Substring (Item[0]. ToString (). IndexOf (",") + 1, item[0]. ToString (). Length-item[0]. ToString (). IndexOf (",")-1); Fly. CityName = City; Fly. Citycode = Citycode; List. ADD (fly); } diclist = Chineseconvert.insertdic (list); } void Button_Click (object sender, EventArgs e) {if (sender as button). Tag = = null) return; Flycity fly = (sender as Button). Tag as flycity; if (stype = = 0) {Lblfromcity.text = fly. CityName; Lblfromcity.tag = Fly; } else {lbltocity.text = fly. CityName; Lbltocity.tag = Fly; } pan_city.visible = false; } private void Pan_titleclick () {foreach (Control item in Pan_citytitle.controls) {if (item is LinkLabel) Item. Click + = new EventHandler (Item_click); }} void Button_mouseleave (object sender, EventArgs e) {(sender as button). BackColor = Color.White; (sender as Button). ForeColor = COLOR.FROMARGB (89, 89, 89); } void Button_mousehover (object sender, EventArgs e) {(sender as button). BackColor = Color.FromArgb (41, 100, 180); (sender as Button). ForeColor = Color.White; } #endregion
Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.
WinForm List of cities to implement selected