Click here to Skip to main content
15,910,083 members
Home / Discussions / C#
   

C#

 
GeneralRe: Response to e-mail sent directly from OP Pin
karayel_kara12-Aug-10 18:15
karayel_kara12-Aug-10 18:15 
GeneralRe: Response to e-mail sent directly from OP Pin
Keith Barrow12-Aug-10 23:12
professionalKeith Barrow12-Aug-10 23:12 
QuestionMasking in C# Pin
Pdaus2-Aug-10 18:28
Pdaus2-Aug-10 18:28 
AnswerRe: Masking in C# Pin
Pete O'Hanlon2-Aug-10 21:37
mvePete O'Hanlon2-Aug-10 21:37 
QuestionThis constraint cannot be enabled as not all values have corresponding parent values Pin
Vimalsoft(Pty) Ltd2-Aug-10 11:42
professionalVimalsoft(Pty) Ltd2-Aug-10 11:42 
AnswerRe: This constraint cannot be enabled as not all values have corresponding parent values Pin
Gopal.S2-Aug-10 17:14
Gopal.S2-Aug-10 17:14 
GeneralRe: This constraint cannot be enabled as not all values have corresponding parent values Pin
Vimalsoft(Pty) Ltd2-Aug-10 21:40
professionalVimalsoft(Pty) Ltd2-Aug-10 21:40 
QuestionChange (or disable) selection color of listview [SOLVED partially] Pin
sodevrom2-Aug-10 8:11
sodevrom2-Aug-10 8:11 
Hello guys,
First, I don't want to use OwnerDraw, that is a condition I have Frown | :( .

What I want is set a custom color to the selection of a listview. I want the color to be visible even if the listview is not focused.
I know about the HideSelection member, but that's not what I need.

I tried to overrwrite the onselectionindexchanged, and make the item.selected=false, and after that, set a custom back/fore color. This does not work because I have multiple items, and it deselects all items but one.

I need one of 2 things:
a)Keep selection visible (with blue color, not gray, this is the problem with HideSelection) always
b)Remember selected objects, but do not show the selection at all (because if the selection is visible, than the custom back/fore color are not visible), so I can "mimic" the selection by setting a custom back/fore color to the items.

Now I have been spending over 4 hours now on this stupid issue, and no luck. Anyone has a suggestion? It would help a lot.

*******************solution
Instead of setting the color in the on selected changed event, we can do it on mouse up. It's not perfect, but it's the best I got. The best way to do this is using a custom draw listview. Here is the code:
List<int> selections=new List<int>();

protected override void OnMouseUp(MouseEventArgs e)
        {
            selections = this.SelectedIndices.Cast<int>().ToList(); //store selection
            this.SelectedIndices.Clear(); //clear selection 

            for (int i = 0; i < this.Items.Count; i++)
            {
                if (this.selections.Contains(i))
                    this.Items[i].BackColor = Color.Blue; //if selected, make it blue
                else
                    this.Items[i].BackColor = Color.White; //if not selected, make it white
            }
            base.OnMouseUp(e);
        }


modified on Monday, August 2, 2010 9:01 PM

AnswerRe: Change (or disable) selection color of listview (not easy :( ) Pin
Eddy Vluggen2-Aug-10 8:23
professionalEddy Vluggen2-Aug-10 8:23 
GeneralRe: Change (or disable) selection color of listview (not easy :( ) Pin
sodevrom2-Aug-10 8:28
sodevrom2-Aug-10 8:28 
GeneralRe: Change (or disable) selection color of listview (not easy :( ) Pin
Eddy Vluggen2-Aug-10 8:47
professionalEddy Vluggen2-Aug-10 8:47 
AnswerRe: Change (or disable) selection color of listview (not easy :( ) Pin
Keith Barrow2-Aug-10 8:35
professionalKeith Barrow2-Aug-10 8:35 
GeneralRe: Change (or disable) selection color of listview (not easy :( ) Pin
sodevrom2-Aug-10 14:26
sodevrom2-Aug-10 14:26 
AnswerRe: Change (or disable) selection color of listview (not easy :( ) Pin
Ennis Ray Lynch, Jr.2-Aug-10 8:46
Ennis Ray Lynch, Jr.2-Aug-10 8:46 
GeneralRe: Change (or disable) selection color of listview (not easy :( ) Pin
sodevrom2-Aug-10 14:25
sodevrom2-Aug-10 14:25 
AnswerRe: Change (or disable) selection color of listview (not easy :( ) Pin
William Winner2-Aug-10 12:32
William Winner2-Aug-10 12:32 
GeneralRe: Change (or disable) selection color of listview (not easy :( ) Pin
sodevrom2-Aug-10 14:24
sodevrom2-Aug-10 14:24 
GeneralRe: Change (or disable) selection color of listview (not easy :( ) Pin
sodevrom2-Aug-10 15:01
sodevrom2-Aug-10 15:01 
AnswerRe: Change (or disable) selection color of listview [SOLVED partially] Pin
V.3-Aug-10 0:08
professionalV.3-Aug-10 0:08 
Questionwhy the form with linkLabel can not get the [Enter] key down event Pin
yu-jian2-Aug-10 7:43
yu-jian2-Aug-10 7:43 
AnswerRe: why the form with linkLabel can not get the [Enter] key down event Pin
I Believe In GOD2-Aug-10 8:01
I Believe In GOD2-Aug-10 8:01 
Questionhelp with import data from csv to access - problem with the (") character Pin
Gali19782-Aug-10 4:11
Gali19782-Aug-10 4:11 
AnswerRe: help with import data from csv to access - problem with the (") character Pin
Ennis Ray Lynch, Jr.2-Aug-10 4:41
Ennis Ray Lynch, Jr.2-Aug-10 4:41 
QuestionSharing a SQL database Pin
Etienne_1232-Aug-10 4:00
Etienne_1232-Aug-10 4:00 
AnswerRe: Sharing a SQL database Pin
PIEBALDconsult2-Aug-10 4:07
mvePIEBALDconsult2-Aug-10 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.