Listview column select

T

Terry Brown

I have created a ListView with multiple columns and populated it with data
in the items and subitems.

Is there anyway to know which cell in the listview has been selected? I
know how to find which row is selected, but I need to know which column
within the row is selected.

I have googled and so on and can't find any reference to this, but it
seems reasonable to do.

Any ideas? Thanks,


Terry
 
D

Daniel Moth

I doubt that is possible. The ListView in Details mode can only tell you
which row is selected (usually you set FullRowSelect = true)

If you describe what is the end user scenario maybe someone can offer
alternatives. Maybe a datagrid is more appropriate for you.

Cheers
Daniel
 
S

Sergey Bogdanov

Maybe you can replace it with DataGrid control? It's possible to get
current selected cell.

Best regards,
Sergey Bogdanov
 
T

Terry Brown

Well, the real problem is that I need to get 10 two-digit numbers readable
across the screen in 200 pixels (I then have 10 rows like this, for a
total of 100 controls). I really want them to be buttons, but there
doesn't appear to be a way to do this effectively. The problem with
buttons is that I can't turn off the borders, nor set the text alignment.
The default spacing of text inside the button leaves way too much space
empty, so with a font size of 8 pt, the button has to be 28 pixels wide to
show both digits. The application needs to know when a particular cell in
the 10x10 array is touched.

I thought perhaps a multicolumn listview would allow me to cram the text
closer together. I have looked at data grid, but it seemed that it wanted
to be bound to a data source, and I don't have or want that.

I had coded this using buttons in evb 3.0 and had no problem, but the
compact framework appears different.

Another problem is that in compact framework, although I can trap the
button click event for multiple buttons, I lost the .tag property I used
in the desktop to identify which button is touched. I guess I will just
look at the location of the button to know this.

Temporarily, what I have done is use buttons that are 28 pixels wide with
font point size 8 and then overlapped the buttons so that the text looks
like it is right aligned (i.e. I moved the button to the right over the
top of the button to the left such that the right button's left border is
nearly touching the left button's text).

I come from a PalmOS background, and I love the simplicity and
productivity of the VS .NET IDE and Visual Basic, but the controls
available seem to leave a bit to be desired.

Thanks for the input,

Terry
 
D

Daniel Moth

Probably the best approach would be to create your own control (inherit from
Control) and do the drawing yourself (override OnPaint) and catch the
clicking based on coordinates (override OnClick). There is a lot of info on
custom controls (google)

Two additional comments:
The datagrid does not have to be bound to a database object, you can use
your own.

If you are handling events from multiple controls (e.g. Button) note the
event handler method signature: It has a sender (As Object) parameter. By
casting the argument to a Button you can test which control sent the event.
In other words, you don't need a Tag property (you could even do it based on
the .Text property)

Cheers
Daniel
 
T

Terry Brown

If you are handling events from multiple controls (e.g. Button) note the
event handler method signature: It has a sender (As Object) parameter. By
casting the argument to a Button you can test which control sent the event.
In other words, you don't need a Tag property (you could even do it based on
the .Text property)

That's what I do, but in the compact framework, there's not a lot there to
use to identify which of 100 controls was clicked. Only the location, I
think, which if fine. Even the Name property is not available in compact
framework. I can't use the text of the button, because that is what I
change when the button is touched.

For the DataGrid, I guess I don't quite see how to use it yet. My
simplistic mind would want to set the values in the cells the same way I
set the text on my buttons, but the documentation says that the item
property is the way to do that and it's not available in the compact
framework. I am kind of coming to the conclusion that the way to do this
is create a data table that I can bind to a data grid and then save and
restore from an xml file. I don't really know how to do that yet, but
I'll figure it out.

To see the application I am working on, take a look at the Hoops
application for PalmOS at my web site. I am porting this application to
PocketPC.

Terry Brown
Stickman Software
http://www.stickmansoftware.com
 
G

Guest

A stylus tap gives a MouseDown event which has the x/y coords of the tap
location in the parent and the parent handle. You can get the x/y of the
parent with respect to the screen through the API, so a little creative
enginering can get you the control tapped (or just keep a list of handles
from creation)

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top