阅读:2202回复:6
用数据库的某个字段做标注时出现了错误
<P>我不能更改其默认的标注字段,请问怎么改掉其默认的字段</P>
<P>Public Sub FunAnnotation(ByVal pFieldName As String) Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass As IFeatureClass Dim pGeoFeatureLayer As IGeoFeatureLayer Dim pActiveView As IActiveView Dim pAnnotateLayerPropertiesCollection As IAnnotateLayerPropertiesCollection Dim pAnnotateLayerProperties As IAnnotateLayerProperties Set pActiveView = pMap ' 判断是否可以开始编辑 If pCurrentLayer Is Nothing Then Exit Sub If Not TypeOf pCurrentLayer Is IGeoFeatureLayer Then Exit Sub Set pFeatureLayer = pCurrentLayer</P> <P> Set pGeoFeatureLayer = pFeatureLayer pGeoFeatureLayer.DisplayField = pFieldName MsgBox pGeoFeatureLayer.DisplayField Set pAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties pAnnotateLayerPropertiesCollection.QueryItem 0, pAnnotateLayerProperties, Nothing, Nothing ' pAnnotateLayerProperties.DisplayAnnotation = True pGeoFeatureLayer.DisplayAnnotation = True</P> <P> pActiveView.Refresh End Sub</P> |
|
1楼#
发布于:2005-07-22 15:37
<P>CODE: <BR><BR>Public Sub AddStreetsLabels() <BR><BR>'Access current active view <BR>Dim pDoc As IMxDocument <BR>Set pDoc = ThisDocument <BR>Dim pMap As IMap <BR>Set pMap = pDoc.FocusMap <BR><BR>'Access the first layer in TOC <BR>Dim pLayer As IGeoFeatureLayer <BR>Set pLayer = pMap.Layer(0) <BR><BR>'Show Tool Tips for a field <BR>pLayer.DisplayField = "ADD_LO_ODD" <BR>pLayer.ShowTips = True <BR><BR>'Set font color <BR>Dim pColorFont As IRgbColor <BR>Set pColorFont = New RgbColor <BR>pColorFont.RGB = RGB(0, 0, 0) <BR><BR>'Set font type, size <BR>Dim pFont As IFontDisp <BR>Set pFont = New StdFont <BR>pFont.Name = "Verdana" <BR>pFont.Size = 4.2 <BR>pFont.Bold = False <BR><BR>'Define text symbol <BR>Dim pText As IFormattedTextSymbol <BR>Set pText = New TextSymbol <BR>pText.Font = pFont <BR>pText.Color = pColorFont <BR><BR>'Create new AnnotateLayerPropertiesCollection <BR>Dim pAnnoPropsCollection As IAnnotateLayerPropertiesCollection <BR>Set pAnnoPropsCollection = New AnnotateLayerPropertiesCollection <BR><BR>'Set up new LabelEngineLayerProperties <BR>Dim pLabelEngine As ILabelEngineLayerProperties <BR>Set pLabelEngine = New LabelEngineLayerProperties <BR>pLabelEngine.Expression = "[STRTNAME]" 'Attribute field to be labeled <BR>Set pLabelEngine.Symbol = pText 'Text symbol from pText <BR><BR>'Set AnnotateLayerProperties to the labels defined above <BR>Dim pAnnoLayerProps As IAnnotateLayerProperties <BR>Set pAnnoLayerProps = pLabelEngine <BR>pAnnoLayerProps.WhereClause = "(STRTNAME = 'KENDRICK CIR')" 'SQL clause <BR>determines <BR><BR>'what features are labeled <BR><BR>'Add AnnotateLayerProperties defined above to the <BR>'AnnotateLayersPropertiesCollection <BR>pAnnoPropsCollection.Add pAnnoLayerProps <BR><BR>'Set the current AnnotateLayerPropertiesCollection to <BR>'the layer's AnnotationProperties and display them <BR>pLayer.AnnotationProperties = pAnnoPropsCollection <BR>pLayer.DisplayAnnotation = True <BR><BR>pDoc.ActiveView.PartialRefresh esriDPGeography, pLayer, Nothing <BR>pDoc.UpdateContents <BR><BR>End Sub <BR></P>
|
|
|
2楼#
发布于:2005-05-09 16:43
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
3楼#
发布于:2005-04-29 13:44
<DIV class=quote>应该加上 pAnnotateLayerPropertiesCollection.clear</DIV>
<DIV class=quote>因为pgeofeaturelayer有一个默认的注记设置,如果没有clear掉,就会重复显示</DIV> <DIV class=quote>另外设置标注字段,需要用到的时LabelEngineLayerProperties的ILabelEngineLayerProperties这个接口,你查查帮助就知道了</DIV> <DIV class=quote> </DIV> <DIV class=quote><B>以下是引用<I>电光火石</I>在2005-4-5 23:34:00的发言:</B></DIV> <P>我不能更改其默认的标注字段,请问怎么改掉其默认的字段</P> <P>Public Sub FunAnnotation(ByVal pFieldName As String) Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass As IFeatureClass Dim pGeoFeatureLayer As IGeoFeatureLayer Dim pActiveView As IActiveView Dim pAnnotateLayerPropertiesCollection As IAnnotateLayerPropertiesCollection Dim pAnnotateLayerProperties As IAnnotateLayerProperties Set pActiveView = pMap ' 判断是否可以开始编辑 If pCurrentLayer Is Nothing Then Exit Sub If Not TypeOf pCurrentLayer Is IGeoFeatureLayer Then Exit Sub Set pFeatureLayer = pCurrentLayer</P> <P> Set pGeoFeatureLayer = pFeatureLayer pGeoFeatureLayer.DisplayField = pFieldName MsgBox pGeoFeatureLayer.DisplayField Set pAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties pAnnotateLayerPropertiesCollection.QueryItem 0, pAnnotateLayerProperties, Nothing, Nothing ' pAnnotateLayerProperties.DisplayAnnotation = True pGeoFeatureLayer.DisplayAnnotation = True</P> <P> pActiveView.Refresh End Sub</P> |
|
4楼#
发布于:2005-04-26 14:43
我用在标注某个字段时,经常不稳定,常常导致VB崩溃。
|
|
5楼#
发布于:2005-04-23 06:42
关注中......
|
|
|
6楼#
发布于:2005-04-06 15:34
我也在刚开始做标注,关注中......
|
|
|