|
my respect
SkyWalker
|
|
|
|
|
how can i use that? please sample code!
|
|
|
|
|
|
hello
i'm stuck on the problem of accessing the sub items of a listview control. the values of sub columns are not being accessed.
i'm using the following code
private void ColumnList_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
ListViewItem selection = ColumnList.GetItemAt(e.X, e.Y);<br />
if (selection != null)<br />
{<br />
MessageBox.Show("Item Selected: "+selection.Text);<br />
}<br />
<br />
}
how ever the following code only accesses the values of the left most column only.
how do i access the values in sub items.
plz do reply.
Saira
|
|
|
|
|
The item has a sub items property, you can iterate over that.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
through the sub item property, items can only be 'added, cleared or removed' and those too only statically.
i want to access the values of the sub items at runtime when the mouse is pressed down on a value.
how can i do this?
|
|
|
|
|
|
well
u can do it ur way but i don't want to give a specific index to lookup its value statically.
i want to give the index od the subitems at runtime, choosing the value of the index by clicking with the mouse on the respected cell of the listView subitem.
can u guide me about it??
|
|
|
|
|
OK, then you need to work out the subitem from the point that was clicked, that's another problem. I'm sure it can be done, doesn't the control expose it's column list, with widths ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
yes the control does expose its column list with widths but i don't need those column widths.
i need to work out a way to give the mouse focus on the rows of the subitem and their different cells.
|
|
|
|
|
Saira Tanwir wrote: but i don't need those column widths.
Of *course* you do...
ListViewItem selection = ColumnList.GetItemAt(e.X, e.Y);<br />
<br />
This is your code. It finds the item, right ? And you need to find the subitem, right ? So, you walk along the column widths and find out which one contains e.Y, that's the one you need.<br />
<br />
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
.... you mean e.X ...
SkyWalker
|
|
|
|
|
Yeah, I do. I am both flabbergasted, and trying to do my own work, so I have not one, but two excuses
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
the code i posted does retrieve the selected item for only those columns which are created through the code
ColumnList.Columns.Add();
however for items inside the sub items cannot be accessed through this code.
|
|
|
|
|
So, the ListViewItem you get back doesn't have a SubItems collection ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
it does have a SubItems collection.
|
|
|
|
|
Then I've told you all you need to know
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thanks for all the help dude;P
i've figured out just another way to solve the problem.
Until Next time
Regards
|
|
|
|
|
can u also guide me about a way to set focus of the mouse on the column and all its cells, whose header is clicked.
|
|
|
|
|
Once you know what the column is, through the method I told you, if there's an API to select a column, you can call it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I wanted to know if i could get a sample code in C# for SetWinEventHook.. This I want to use to track the events(Mouse and KeyBoard) in a .NET Application..
After that, Is there a way, that i can use this API(SetWinEventHook) like SetWindowsHookEx to inject code into the target Application's Address space and get the Control information on which the Mouse is Clicked?
Regards
Pattu
|
|
|
|
|
www.pinvoke.net[^] is the place to go if you want to call Win32 APIs in C#.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi Graus,
I actually looked at www.pinvoke.net.. But I wanted a Sample code to use this API...
It would be great if i can get it..
Regards
Pattabhi
|
|
|
|
|
Google for it. The point of pinvoke is that you're calling a Win32 API, so the Win32 docs is the place to look for help on how to call it
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild,
uint dwEventThread, uint dwmsEventTime)
|
|
|
|