473,748 Members | 10,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listview Rectangle Focus problem

I've tried working with the SelectedIndices and Items[##].Selected
attributes to get the problem to go away, but not having any luck.

Questions I have are:

1) How do you move (using code) the focus Rectangle when your Selected
Index changes ?
2) If there are no selected rows, can that focus rectangle be removed?
3) What other quirks exist in this simple example I might need to code
for ?

On the Listview, I'm using "MultiSelec t = True" and "FullRowSel ect =
True".

//
// Detail
//

When the application first starts up, the Listview has focus. No
selection has been clicked, but a simple rectangle outlines the first
record.

http://i11.photobucket.com/albums/a1...3/01_Start.jpg
If I press Cursor Up, nothing highlights. If I press Cursor Down, the
2nd row highlights and the Focus rectangle moves to 2nd row:

http://i11.photobucket.com/albums/a1...CursorDown.jpg

Double clicking the row launches my Editor Form, in this example I
double click the 2nd Row item.

I pass the ListView object from the Main Form to the Editor. In my
Editor, I have [Previous] [Next] buttons. I click the "Previous"
button and the Main ListView changes focus to the 1st record.

http://i11.photobucket.com/albums/a1.../03_Editor.jpg

//
// Code for Previous click:
//

private void cmdPrevious_Cli ck(object sender, System.EventArg s e)
{
if (_ListView.Sele ctedIndices[0] > 0 )
{
int iNewIndex = _ListView.Selec tedIndices[0]-1;

// Remove Current Highlighted Record
_ListView.Items[_ListView.Selec tedIndices[0]].Selected = false;

// Highlight Previous record
_ListView.Items[iNewIndex].Selected = true;
_ListView.Refre sh();
}
}

//
// Code (Image) for Previous click:
//

http://i11.photobucket.com/albums/a1...r_Previous.jpg

I finish the Edit and close the Editor Form, the Main Form now has the
first row highlighted -AND- the focus Rectangle is still on the 2nd
row.

http://i11.photobucket.com/albums/a1..._AfterEdit.jpg

Pressing Cursor Down does nothing. Pressing Cursor Up moves the focus
Rectangle to the 1st Row and it remains highlighted.

http://i11.photobucket.com/albums/a1...5_CursorUp.jpg

Help!

Nov 17 '05 #1
1 5049
Tinkering around with it some more, I finally discovered the solution
in case it helps anyone else in the future.

Had to add one more item call:

_ListView.Items[iNewIndex].Focused = true;

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
21259
by: John Lauwers | last post by:
I know you can edit the first column of the listview control, is there a way to edit the second and/or the other columns? greets John
0
1254
by: timtos | last post by:
I just started to create my own ListView control and already have big problems... I use the following code at the moment: protected override void OnPaint(PaintEventArgs pe) { this.SuspendLayout(); if (this.View == View.Details) { Graphics g = pe.Graphics;
1
2392
by: Steve | last post by:
I have a listview that can get itself into a situation where multiple items have the LVIS_FOCUSED state. According to the documentation, LVIS_FOCUSED means "The item has the focus, so it is surrounded by a standard focus rectangle. Although more than one item may be selected, only one item can have the focus. So how is it that I have multiple items with the focused state? Is this a bug in the Windows API? I am using Windows XP with the...
2
2936
by: Matt Michael | last post by:
Hi, I'm having a problem working with a listview in an application I'm writing. Currently, whenever the selectedindex changed event fires, it loads up a htmledit control, and other labels on the form, with the current information associated with the listview item. The control is called HtmlEdit and it references Microsoft.Mshtml Whenever I click on each item, it works fine, but it seems that whenever I use the up/down arrows(important)...
0
1637
by: Brian Henry | last post by:
Ok whats going on here... got a couple problems... this is relevant now to this group since .NET 2.0 is finally RTM 1) draws really slow when making it a large form (resizing speed is jerky) to a res from 100x100 to 1280x1024 once it gets above 500x500 it starts jerking you can see the screen refreshing as it paints 2) sometimes the background selection when you select multiple items then move the mouse around on the screen dissapear...
5
1803
by: --== Alain ==-- | last post by:
Hi, Several months ago i've asked some information about the best way how to have some particular columns (progress bar, checkbox, images, color picker,...) in a ListView component. It seems that ListView is a complex component and a lot of people advise to build a custom component but not from ListVIew itself. Some use a datagrid component as base component, some build a component
5
12666
by: Jure Bogataj | last post by:
Hi all! I have a problem (performance issue) with listview. I have implemented an ItemSelectionChange on my listview and put some code in it (I build some toolbar based on selection and update info in statusbar). When selecting one item (clicking on listview) it works fast, without noticing. However if selecting multiple items with SHIFT (approx. 500 items) or selecting with mouse, for each item selected through all listview an event...
0
4661
by: =?Utf-8?B?SWdvcg==?= | last post by:
Hi everyone! I have some strange behavior of ListView control in WPF. We are developing application in C#. I created ListView with some items and set SelectedIndex to some index in the middle of its list. Then I clicked mouse at any place on the ListView and then navigate with Up/Dows keyboard keys, everything works perfectly. But If I move focus to another control and then tries to set focus back to ListView
7
8891
by: prpradip | last post by:
I have used ListView in my Form. I have set OwnerDraw = true. And I have the DrawItem Function as private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { if (e.Item.Checked) ControlPaint.DrawCheckBox(e.Graphics, 0, e.Bounds.Top + 1, 15, 15, ButtonState.Flat | ButtonState.Checked); else ...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.