Click here to Skip to main content
15,917,176 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regular Expressions Pin
Dustin Metzgar2-Jun-06 4:42
Dustin Metzgar2-Jun-06 4:42 
GeneralRe: Regular Expressions Pin
J4amieC2-Jun-06 4:45
J4amieC2-Jun-06 4:45 
GeneralRe: Regular Expressions Pin
Paul Conrad2-Jun-06 4:51
professionalPaul Conrad2-Jun-06 4:51 
GeneralRe: Regular Expressions Pin
Dustin Metzgar2-Jun-06 4:57
Dustin Metzgar2-Jun-06 4:57 
GeneralRe: Regular Expressions Pin
J4amieC2-Jun-06 5:29
J4amieC2-Jun-06 5:29 
GeneralRe: Regular Expressions Pin
Dustin Metzgar2-Jun-06 5:48
Dustin Metzgar2-Jun-06 5:48 
GeneralRe: Regular Expressions Pin
Stephan Samuel2-Jun-06 6:18
Stephan Samuel2-Jun-06 6:18 
QuestionHow to retrieve a text from a selected item in a ListView?? Pin
suguimoto2-Jun-06 4:15
suguimoto2-Jun-06 4:15 
Hello!

I would like to know how to retrieve a text from a selected item in a ListView.

I have "translated" a code that does it, from old VB to C#, but I think my problem is how to reference my structure LV_ITEM to the SendMessage.
some pieces of my Code:
[DllImport("user32.dll")]
public static extern int SendMessageA(IntPtr hwnd, int Msg, int wParam, LV_ITEM LV);
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, int Msg, int wParam, int lParam);
private const int LVM_FIRST = 0x1000;
private const int LVM_GETITEMSTATE = (LVM_FIRST + 44);
private const int LVM_GETITEMTEXT = (LVM_FIRST + 45);
private const int LVIS_STATEIMAGEMASK = 0xF000;

public struct LV_ITEM
{
int mask;
int iItem;
int iSubItem;
int state;
int stateMask;
string pszText;
int cchTextMax;
int iImage;
int lParam;
int iIndent;
}
private void button1_Click(object sender, EventArgs e)
{
int r;
LV_ITEM LV = new LV_ITEM();
string b;
b = "The following ListView items are checked: " + "\r\n";
for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
r = SendMessage(listView1.Handle, LVM_GETITEMSTATE, i, LVIS_STATEIMAGEMASK);
if (r == 8192) // r returns 8192 if the current item is selected
{
LV.cchTextMax = MAX_PATH;
LV.pszText = " ";
SendMessageA(listView1.Handle, LVM_GETITEMTEXT, i, LV); //here appears the error
b = b + LV.pszText + "\r\n";
MessageBox.Show(LV.pszText);
}
}
MessageBox.Show(b);
}

I have read something about in, out, I don´t remember exactly if it has something to do with these.

Thanks!
AnswerRe: How to retrieve a text from a selected item in a ListView?? Pin
suguimoto2-Jun-06 4:50
suguimoto2-Jun-06 4:50 
AnswerRe: How to retrieve a text from a selected item in a ListView?? Pin
Ravi Bhavnani2-Jun-06 10:44
professionalRavi Bhavnani2-Jun-06 10:44 
QuestionMS Access Password Pin
abeberness2-Jun-06 3:55
abeberness2-Jun-06 3:55 
QuestionCode review wanted Pin
Emma Burrows2-Jun-06 2:41
Emma Burrows2-Jun-06 2:41 
AnswerRe: Code review wanted Pin
Dan Neely2-Jun-06 3:40
Dan Neely2-Jun-06 3:40 
GeneralRe: Code review wanted Pin
Emma Burrows2-Jun-06 22:16
Emma Burrows2-Jun-06 22:16 
AnswerRe: Code review wanted Pin
leppie2-Jun-06 9:39
leppie2-Jun-06 9:39 
GeneralRe: Code review wanted Pin
Emma Burrows2-Jun-06 22:15
Emma Burrows2-Jun-06 22:15 
AnswerRe: Code review wanted Pin
Emma Burrows10-Jun-06 1:03
Emma Burrows10-Jun-06 1:03 
QuestionHow to use user32.dll PostMessage function. Pin
Larantz2-Jun-06 2:02
Larantz2-Jun-06 2:02 
AnswerRe: How to use user32.dll PostMessage function. Pin
Ravi Bhavnani2-Jun-06 2:33
professionalRavi Bhavnani2-Jun-06 2:33 
General[Solved it]Re: How to use user32.dll PostMessage function. [modified] Pin
Larantz2-Jun-06 3:06
Larantz2-Jun-06 3:06 
GeneralRe: How to use user32.dll PostMessage function. Pin
Larantz2-Jun-06 3:33
Larantz2-Jun-06 3:33 
GeneralRe: How to use user32.dll PostMessage function. Pin
e87t53iu19-Oct-09 21:56
e87t53iu19-Oct-09 21:56 
QuestionEmpty DataSet??? Pin
NaNg152412-Jun-06 1:20
NaNg152412-Jun-06 1:20 
AnswerRe: Empty DataSet??? Pin
H. Neville III2-Jun-06 3:06
H. Neville III2-Jun-06 3:06 
QuestionRe: Empty DataSet??? Pin
NaNg152412-Jun-06 3:25
NaNg152412-Jun-06 3:25 

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.