Zoom to selected problem

Dec 9, 2012 at 3:48 AM
Edited Dec 11, 2012 at 3:02 PM

i use zoomtoselectfeatures command to my following code below:

private void dgvAttributeData_SelectionChanged(object sender, EventArgs e)
        {

            string sRowVal = "";
            foreach (DataGridViewRow row in dgvAttributeData.SelectedRows)
            {
                if (rdoLyrGerai.Checked)
                {
                    MapPointLayer mapLayer = default(MapPointLayer);
                    mapLayer = (MapPointLayer)map1.Layers[5];
                    if (mapLayer == null)
                    { MessageBox.Show("The layer is not a point layer."); }
                    else
                    {
                        sRowVal = row.Cells[cboLayer.Text.ToUpper().Trim()].Value.ToString();
                        mapLayer.SelectByAttribute("[" + cboLayer.Text.ToUpper().Trim() + "] =" + "'" + sRowVal + "'");
                        mapLayer.ZoomToSelectedFeatures();
                       
                    }
                }
                else if (rdoLyrAlfa.Checked)
                {
                    MapPointLayer mapLayer = default(MapPointLayer);
                    mapLayer = (MapPointLayer)map1.Layers[5];
                    if (mapLayer == null)
                    { MessageBox.Show("The layer is not a point layer."); }
                    else
                    {
                        sRowVal = row.Cells[cboLayer.Text.ToUpper().Trim()].Value.ToString();
                        mapLayer.SelectByAttribute("[" + cboLayer.Text.ToUpper().Trim() + "] =" + "'" + sRowVal + "'");
                        mapLayer.ZoomToSelectedFeatures();
                    }

                }
                else if (rdoLyrJalan.Checked)
                {
                    MapLineLayer mapLayer = default(MapLineLayer);
                    mapLayer = (MapLineLayer)map1.Layers[3];
                    if (mapLayer == null)
                    { MessageBox.Show("The layer is not a point layer."); }
                    else
                    {
                        sRowVal = row.Cells[cboLayer.Text.ToUpper().Trim()].Value.ToString();
                        mapLayer.SelectByAttribute("[" + cboLayer.Text.ToUpper().Trim() + "] =" + "'" + sRowVal + "'");
                        mapLayer.ZoomToSelectedFeatures();
                                               
                    }
                }
                else if (rdoLyrKampusSekolah.Checked)
                {
                    MapPointLayer mapLayer = default(MapPointLayer);
                    mapLayer = (MapPointLayer)map1.Layers[8];
                    if (mapLayer == null)
                    { MessageBox.Show("The layer is not a point layer."); }
                    else
                    {
                        //mapLayer.SelectByAttribute("[FID] =" + "'" + row.Cells["FID"].Value + "'");
                        sRowVal = row.Cells[cboLayer.Text.ToUpper().Trim()].Value.ToString();
                        mapLayer.SelectByAttribute("[" + cboLayer.Text.ToUpper().Trim() + "] =" + "'" + sRowVal + "'");
                        mapLayer.ZoomToSelectedFeatures();
                    }
                }
                else if (rdoLyrPerbelanjaan.Checked)
                {
                    MapPointLayer mapLayer = default(MapPointLayer);
                    mapLayer = (MapPointLayer)map1.Layers[6];
                    if (mapLayer == null)
                    { MessageBox.Show("The layer is not a point layer."); }
                    else
                    {
                        sRowVal = row.Cells[cboLayer.Text.ToUpper().Trim()].Value.ToString();
                        mapLayer.SelectByAttribute("[" + cboLayer.Text.ToUpper().Trim() + "] =" + "'" + sRowVal + "'");
                        mapLayer.ZoomToSelectedFeatures();
                    }
                }
            }
        }

if i use this code to line or polygon layer, it run normaly. but if i use this code to point layer, my line and polygon layer going to shrink like zoom out function. are this a bug or i doing wrong with code?