For project reasons, the customer needs a map and each layer is displayed. the last layer contains the features of all branches. He wants to query data by selecting the features. TMD, this is the first time he has done this, the core is just a few words. It is very convenient to add layers. It is really complicated to search for features. If you have no books or materials, go to ERSI for help! E. Headaches
The Code is as follows:
Lstdept. Items. Clear (); // display the ListBox of the branch name
Lstid. Items. Clear (); // ListBox of the branch ID
Mapobjects2.rectangle prect = axmapobj. trackrectangle (); // use the giant area selected by the mouse
Mapobjects2.recordset pdaord = NULL;
Mapobjects2.maplayer layer = (mapobjects2.maplayer) axmapobj. layers. Item (0); // The top layer. axmapobj is the name of the map control.
Pdaord = Layer. searchshape (prect, mapobjects2.searchmethodconstants. mocontaining, ""); // use the DaO object, mainly the searchshape Method
If (pdaord! = NULL) pdaord. movefirst ();
While (! Pdaord. EOF)
{
String sdeptname = "";
String sdeptid = "";
Sdeptname = pdaord. Fields. Item ("unitname"). valueasstring;
Sdeptid = pdaord. Fields. Item ("unitid"). valueasstring;
If (sdeptname! = String. Empty & sdeptid! = String. Empty)
{
Lstdept. Items. Add (sdeptname );
Lstid. Items. Add (sdeptid );
}
Pdaord. movenext ();
}
This code is stored in the mousedownevent event of the axmapobj map control. Now, find the branch number and use the query in your database! My homepage: itbaby.jss.cn