Click here to Skip to main content
16,022,418 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I am using a ListBox and I added 15 items into that listbox.
Some items names are around 25 characters long.
When I try to select an item by clicking at the ending 2 characters of the item, it's not selecting. If I try to select the same item at the beginning it's selecting.


For Example:

My ListBox Contains 3 items

1.Subhash Chandra Sekhar
2.ABC
3.BCD
4.Example of ListBox items

In 1. if i am clicking at subhash it's selecting but if i am clicking at har in sekhar it's not selecting.

In 4. if i am clicking at example it's selecting but if i am clicking at items it's not selecting.


What's the problem?
Help me out from this.

Comment from OP:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Xml;
namespace ReadingDoucment
{
    public partial class Form1 : Form
    {
        HelpItem h1;
        Help h2;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (HelpItem hi in Help.GetHelpItems())
            {
                listBox1.Items.Add(hi);
                listBox1.DisplayMember = "Label";
            }
            listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
        }

        void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            HelpItem hi = listBox1.SelectedItem as HelpItem;
            if (hi != null)
            {
                LoadFile(hi.File);
            }
        }

        void LoadFile(string file)
        {
            if (File.Exists(file))
            {
                richTextBox1.LoadFile(file, RichTextBoxStreamType.RichText);
            }
            else
            {
                richTextBox1.Clear();
                MessageBox.Show("File Not Exist", "Exception");
            }
        }
    }
}

- subhash04573 6 hrs ago.
Posted
Updated 20-Dec-10 10:10am
v7
Comments
Abdul Quader Mamun 17-Dec-10 1:13am    
Spelling check.
Tarun.K.S 20-Dec-10 8:43am    
well thats pretty strange. Can you share the code?

1 solution

I can't understand your problem.
Try these properties in ListBox
ListBox.FullRowSelect = true;
ListBox.View = ListView.Details;
 
Share this answer
 
v2
Comments
subhash04573 20-Dec-10 8:36am    
FullRowselect property is for ListView not for ListBox.
subhash04573 20-Dec-10 8:41am    
Hi,

I am using a ListBox and I added 15 items into that listbox.
Some items names are around 25 characters long.
When I try to select an item by clicking at the ending 2 characters of the item, it's not selecting. If I try to select the same item at the beginning it's selecting.


For Example:

My ListBox Contains 3 items

1.Subhash Chandra Sekhar
2.ABC
3.BCD
4.Example of ListBox items

In 1. if i am clicking at subhash it's selecting but if i am clicking at har in sekhar it's not selecting.

In 4. if i am clicking at example it's selecting but if i am clicking at items it's not selecting.


What's the problem?
Help me out from this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900