Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

If I load a layer via a shapefile and set

((ILayer)myLayer).ShowTips = true; 

How can I change the tip content (I want to point it to a different column or have a expression of multiple columns) programatically with ArcEngine 10 and C#?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Take a look at the DisplayField on the IFeatureLayer for changing attribute field. For more advanced formating check out the IDisplayString and IDisplayExpressionProperties.

Made some code this work for me:

private void startMapTipsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ILayer layer = axMapControl1.Map.get_Layer(0);
            axMapControl1.ShowMapTips = true;
            IFeatureLayer fLayer = layer as IFeatureLayer;

            fLayer.ShowTips = true;
            fLayer.DisplayField = "AREANAME";

        }

        private void startMapTipsAdvancedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ILayer layer = axMapControl1.Map.get_Layer(0);
            axMapControl1.ShowMapTips = true;
            IFeatureLayer fLayer = layer as IFeatureLayer;

            fLayer.ShowTips = true;

            IDisplayString displayString = fLayer as IDisplayString;
            IDisplayExpressionProperties properties = displayString.ExpressionProperties;

            properties.Expression = "[AREANAME] & vbnewline & [POP2000]";
        }
share|improve this answer
    
I did that and got no errors, but the tips don't display, do you have any ideas about why they wouldn't display –  patrick Oct 27 '10 at 14:56
    
@iterationx, exactly what did you do? –  MathiasWestin Oct 27 '10 at 15:12
    
IFeatureLayer thisFeatureLayer = thisLayer as IFeatureLayer; thisFeatureLayer.DisplayField = "OWNER_NAME"; thisFeatureLayer.ShowTips = true; –  patrick Oct 27 '10 at 15:21
1  
@iterationx, I've added some code that work for me. –  MathiasWestin Oct 27 '10 at 15:39
    
Thanks, my problem was that I had not enabled MapTips via axMapControl1.ShowMapTips = true; –  patrick Oct 27 '10 at 15:45
add comment

ILayer.ShowTips Property: Indicates whether or not map tips are shown for the layer. If set to True, then map tips will be shown for the layer. You can determine the text that will be shown via TipText. For a FeatureLayer, this text comes from the data for IFeatureLayer::DisplayField.

In your case that would be a simple

((IFeatureLayer)myLayer).DisplayField = "colName";
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.