Solved

how to move a label on columnwidth changeevent in listview --C# windows form

Posted on 2007-11-17
4
564 Views
Last Modified: 2013-12-17
how to move a label on columnwidth changeevent in listview --C# windows form

i had a list view i want the sieze to be of 12 but the column name should be of 8 so i placed a label on that with 8 font but when ever i move the coloumn the label should also be moved
so can any one tell me how to move the label in columnwidth change event
0
Comment
Question by:kranthi4uonly
  • 2
  • 2
4 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20306100
Doesn't seems like a clean solution, maybe you can try to derive a custom listview control and override the OnDrawColumnHeader method.
Here is an example where text alignment in header is changed, but you can modify to draw with a smaller font:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic54640.aspx
0
 

Author Comment

by:kranthi4uonly
ID: 20310411
hi  ihad developed the user defined control as u said the code follows like this
private void UserControl1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            using (StringFormat sf = new StringFormat())
            {
                // Draw the header text.
                using (Font headerFont = new Font("Microsoft Sans Sarif", 8, FontStyle.Regular))
                {
                    e.Graphics.DrawString(e.Header.Text, headerFont,
                        Brushes.Black, e.Bounds, sf);
                }
            }  
        }

but my problem is when iam inheriting it and trying to add items from list box i cannot see any items in list view but ican see the scroll ball growing when i click the button the code for insert is as follows

private void button1_Click(object sender, EventArgs e)
        {
 string t = listBox1.SelectedItem.ToString();
            ListViewItem lv = new ListViewItem(t);
            userControl11.Items.AddRange(new ListViewItem[] { lv });
}
can u tell me the reason please
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20310467
0
 

Author Comment

by:kranthi4uonly
ID: 20311075
excellent but can't i click on the column for sorting
right now i can't click the column
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now