Click here to Skip to main content
15,912,400 members
Home / Discussions / C#
   

C#

 
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 
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 
This is a very basic solution, but here it is anyway:

C#
private List<int> selections = new List<int>();
private bool dontChange = false;

private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (!dontChange)
    {
        dontChange = !dontChange;
        int selectedIndex = listView2.SelectedIndices[0];

        listView1.SelectedIndices.Clear();

        //check if we're deselecting/selecting
        if (selections.Contains(selectedIndex))
        {
            selections.Remove(selectedIndex);
            listView1.Items[selectedIndex].BackColor = Color.White;
        }
        else
        {
            selections.Add(selectedIndex);
            listView1.Items[selectedIndex].BackColor = Color.Blue;
        }
    }
    else
    {
        dontChange = !dontChange;
    }
}


of course this only works if you're selecting one item at a time. If you're doing an extended selection (meaning using Ctrl or Shift to select items) it wouldn't work because when you click the first time, it will add the item, then when you click the second time, it tries to make all of the items selected, which would deselect the first item. You'd have to include some key checking to see if Ctrl or Shift was down.
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 
GeneralRe: Sharing a SQL database Pin
Etienne_1232-Aug-10 4:11
Etienne_1232-Aug-10 4:11 
GeneralDepends Pin
Ennis Ray Lynch, Jr.2-Aug-10 4:37
Ennis Ray Lynch, Jr.2-Aug-10 4:37 
GeneralRe: Depends Pin
PIEBALDconsult2-Aug-10 12:05
mvePIEBALDconsult2-Aug-10 12:05 

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.