CListCtrl Setting the Focus to a Row through Code

Hi

i am taken a dialog based application. on the dialog i placed
CListCtrl.i added 3 cols and 10 row to the list control. the first
column is Checkbox.
On the dialog box i placed two Buttons with captions "Next" and
"Previous". when i run my application, when i Press "Next" Button the
selection mark in the CListCtrl should move to the next row.and when i
press "Previous" the selection mark in the CListCtrl should move to the
previous row.

i am using

nItem=5;
 m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED,
LVIS_SELECTED|LVIS_FOCUSED );

its not working.

is am i doing in the corret way?. if not how do it?.

Thanks..

0
11/28/2005 5:14:30 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
985 Views

Similar Articles

[PageSpeed] 19

>nItem=5;
> m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED,
>LVIS_SELECTED|LVIS_FOCUSED );
>
>its not working.

Is it not working, or are you just not seeing the selection indicator
when the control doesn't have focus?

Dave
0
davidl7375 (2060)
11/28/2005 8:22:34 AM
after SetItemState function, i am using the following code to check
whether the new row is effected or not

 pos = m_ListCtrl.GetFirstSelectedItemPosition();
 nItem = m_ListCtrl.GetNextSelectedItem(pos);

also, it is not having the foucs,so it is not displaying the selection
indicator.i need to scroll the selection status to the new row.

0
11/28/2005 8:44:06 AM
>after SetItemState function, i am using the following code to check
>whether the new row is effected or not
>
> pos = m_ListCtrl.GetFirstSelectedItemPosition();
> nItem = m_ListCtrl.GetNextSelectedItem(pos);

I'm not sure what's happening there. Have you just tried
GetNextItem(-1, LVNI_SELECTED) instead?

>also, it is not having the foucs,so it is not displaying the selection
>indicator.

Give the control the LVS_SHOWSELALWAYS style.

Dave
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl7375 (2060)
11/28/2005 11:31:20 AM
Thank you Mr.David Lowndes

i solved my problem. the problem is , when i use the "Next" button to
scroll to the next row, the list Control is losing its focus.

now i setting the focus to the list control again. then it is working
as i desired.

m_ListCtrl.SetFocus();
nItem=5;
 m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED,
LVIS_SELECTED|LVIS_FOCUSED ); 

Once again Thanks Mr.David Lowndes

0
11/29/2005 2:57:29 AM
Reply:

Similar Artilces:

Filter/Display only certain rows of information based on a user na
Good Morning, I have a spreadsheet that contains a list of employee names (In Column "A") and information across a row related to them....Each employee is under 1 of 4 managers and what I need to do is have a way for the manager to log into the spreadsheet and only display the employees that is under them. Thank you in advance for your help, George Is the exclusivity down to confidential data or is it just to make it easy for the Managers to see their own staff? Is there a column that contains the Manager's name? If so and if confidential matter is not a p...

How do I set up group emails from specific account contacts?
-- Big Tex huh? "GLOVE GUY" <GLOVEGUY@discussions.microsoft.com> wrote in message news:0A7D81FC-12CE-4AF5-8A1A-A88394AEBB8A@microsoft.com... > > -- > Big Tex ...

OWA settings
Hi am still stuggling with setting OWA up on my 2003 exchange box. Can someone with Exch 2003 check a few settings in IIS for me so I confirm it is setup correctly. When I try to connect via the lAN (for testing purposes) it says access denied. Here are my settings: Default web site is set to anonymous access. Exchange virtual directory is set to Integrated and basic. I have no SSL applied to the site. One thing I have noticed is the defaut application pool is stopped could someone please confirm this is the correct setting. The exchange application pool is running. I am really strugg...

How do I set up an automatic delete or move of a row of data?
I have a job summary that lists the status of my projects. I want to move the data and close up the gaps in the spreadsheet as I change the status to "complete". You need to provide more information. For example, how do you change the status to complete and where do you want to move the data to? Regards Rowan "Zo" wrote: > I have a job summary that lists the status of my projects. I want to move > the data and close up the gaps in the spreadsheet as I change the status to > "complete". I have a list that identifies the "status" of th...

Setting up News Groups
How do I set up Newsgroups using Outlook 2007? Douglas ddwashington@sbcglobal.net wrote: > How do I set up Newsgroups using Outlook 2007? > > Douglas > > You don't. Grab a copy of, say, Thunderbird and use that just for Newsgroups. If your ISP allows feeds of Newsgroups set it up through them in Thunderbird. Otherwise sign up for one of the free ones, like Motzarella and set up the Groups from within Thunderbird, using Motzarella.org as the News provider. No need to use Thunderbird for anything but the Newsgroups, if that is your fancy. Of course you coul...

how do i keep adding to existing total in same row
i want cells a & B to be incoming and out going numbers and cell c to total accordingly. i have that part but want a & b cells to be reinputted band total change with new inputs so that total continues to grow or shrink with each new imput want to reuse same a & B cell agian and agian Look here: http://www.mcgimpsey.com/excel/accumulator.html -- Kind regards, Niek Otten Microsoft MVP - Excel "marklessexcel" <marklessexcel@discussions.microsoft.com> wrote in message news:A596C782-1E01-43C4-9474-A384F69630F7@microsoft.com... >i want cells a & B t...

CListCtrl Header height change??
CListCtrl Header height change?? Is it possible to change the height of a CListCtrl Header.? Thanks Markus ...

how do i set outgoing server different from incoming server?
the server i use to receive email is panhandle.rr.com. at home, my internet connection is provided through charter calbe though. i set up my email in outlook and can receive emails but i can't send any emails. they all come back with the message "undeliverable" through the online help topics, it says i need to setup my email account with different incoming pop3 and outgoing smtp addresses, but it doesn't explain how. please help!!!! karen What version of Outlook are you using? "karebear" <karebear@discussions.microsoft.com> wrote in message news:...

Problems with CListCtrl
I'm having trouble with a CListCtrl object. I'm trying to automatically set the selected items of the list from my code. I try the following statement: m_List.SetItem (pos, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED, LVIS_SELECTED, 0); The SetItem function returns non-zero, which supposedly means it was successful. However, I don't see any selection showing up. I even called RedrawItem on this list item, but it didn't help either. Anyone know about this? -Eric >I'm having trouble with a CListCtrl object. I'm trying to automatically >set the selected ite...

The code below worked for a few days and just totally stopped working.
The code below worked for a few days and just totally stopped working. What can I do to make sure it continues to work? Thanks! ----- Private Sub Worksheet_Change(ByVal Target As Range) Dim C As Range, D As Range Set D = Intersect(Range("A:A"), Target) If D Is Nothing Then Exit Sub For Each C In D On Error Resume Next Target.Offset(0, 6).FormulaR1C1 = "=RC[-2]&RC[-5]" ' - For Column E Target.Offset(0, 7).FormulaR1C1 = "=RC[-2]&RC[-5]" ' - For Column F Target.Offset(0, 9).FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC7,I.O.! R2C1:R57...

CTreeCtrl and CListCtrl problem
I use create a single document struct using MFC(explore style).The left of the window is CLeftView class(which inherit CTreeView).The right is CBrowserView which inherit CListView.I want to display the content of a directory in the right(CListview) when user click the item of the ctreectrl. In the LeftViw I add method "void CLeftView::OnClickItem (NMHDR* pNMHDR, LRESULT* pResult)" because I want to know which item be clicked by user. ////////////////Leftview////////////////////// CTreeCtrl& mtree=GetTreeCtrl(); HTREEITEM item=mtree.GetSelectedItem(); data=mtree.GetItemDat...

CListCtrl and sub item editting
Hi, Is it possible to implement CListCtrl sub item editting without creating a custom ctrl? I am using VS2003. TIA Tony >Is it possible to implement CListCtrl sub item editting without creating a >custom ctrl? Tony , There's no built-in support for this, so no, you have to provide some implementation for this. Have a look on sites such as CodeGuru and CodeProject, they'll have examples. Dave Thanks Dave, I've seen examples, I just wasnt sure if I needed my own ctrl. Regards Tony "David Lowndes" <DavidL@example.invalid> wrote in message news:k...

Visual Basic code for macros
I'm trying to write a macro to transfer new data from one sheet in a workbook to another. To do it I need to navigate from the active cell to others by using the active cell as a reference point and moving by "R[+n]C[-x]" rather than by a specific cell address (eg H4) referenced from the top left corner. Is there a way I can get a useable return from the ActiveCell function, or any other code structure that might give me the result I'm looking for? I'm using Excel 2002 and Visual Basic Version 6.3. Thank you. maybe you could use activecell.offset(n,-x) Derek...

XML from file to code
hi I' reading an xml file from an external location the encoding: <?xml version="1.0" encoding="iso-8859-1" ?> My problem is, when I read the data from the xml element with element.firstchild.value, some special characters disapear. sample: <tag>abc�</tag> element.firstchild.value returns abc the special char "�" is gone. please help! Apogee Apogee wrote: > I' reading an xml file from an external location > the encoding: <?xml version=3D"1.0" encoding=3D"iso-8859-1" ?> >=20 > My problem is,...

How to add clistctrl into clistctrl?
How to clistctrl into a clistctrl? For example like adding checkbox , combobox, i want to add clistctrl into a clistctrl ...

Inserting a Row Every "X" Rows
Does anyone know how you might go about inserting a extra row inbetween rows at certain intervals. For instance, auto insert of rows every 3rd row, etc. One way Sub test() Application.ScreenUpdating = False Dim numRows As Integer Dim R As Long Dim rng As Range numRows = 3 Set rng = ActiveSheet.UsedRange For R = rng.Rows.Count To 1 Step -1 rng.Rows(R + 1).Resize(numRows).EntireRow.insert Next R Application.ScreenUpdating = True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "JMS" <jms@skillsconsulting.com> wrote in me...

Write record from Form to new row in spreadsheet
I am using a form to provide input into a spreadsheet. Every time I write a record, I want it to write to a new line in the spreadsheet. When I first used this code, it wrote on the second line in the spreadsheet, even though there was a second header line there and it overwrote the line. When I took out the first header, it wrote on the second line okay. However, when I tried to enter a new record, it overwrote the first record. Basically I want to write the first new record on the third line (after two header lines) and then each new record on the next available line, etc. Be...

Setting up a Metrologic Stratos 2320 with POS 2009
Has anyone connected a Stratos 2320 (Scanner-Scale) with Microsoft Dynamics POS 2009. And if you have can you please provide the steps you used to accomplish it. Thanks Problem solved: The Stratos 2320 come out of the factory as a dual cable connection and if you get a single cable connection you will need to follow Honeywells instructions to change the configuration. So if any one needs this PDF document please let me know and please provide me with your email address and I will send it to you. "Papashawngo" wrote: > Has anyone connected a Stratos 2320 ...

How do I set all folders automatically to DETAIL view?
How do I set my computer so that all folders, subfolders, etc. open in DETAIL view automatically instead of SMALL ICONS? I am very tired of having to change the view every day, every folder, etc. Thank you for your assistance. And, shouldn't it be easier to find this information in the system than having to post to other uses or Microsoft staff? Just a thought. Assuming Windows Vista: open any folder in your Windows explorer and set the way you want all your folders to look. Press ALT to make the menu bar show up. Then take Tools -> Folder Options -> View tab. Th...

Flipping column and row headings #2
Hello, I need to flip the column and row headings. Is this possible? Thanks, Steve Steve, I think you should use the transpose formula, you highlight say the column area A2:A11 and type =TRANSPOSE(B1:B10) and finish with Ctrl+Shift+Enter. Give it a whirl... "seve" wrote: > Hello, > > I need to flip the column and row headings. > > Is this possible? > > Thanks, > > Steve > > ...

lead zeroes in zip codes
How do you do a spread sheet and maintain a lead zero in the zipcode (example 08550 shows up as 8550)? "fred rosenfeld" <frosenfeld@comcast.net> wrote in message news:0dd701c35758$4325dfc0$a101280a@phx.gbl... > How do you do a spread sheet and maintain a lead zero in > the zipcode (example 08550 shows up as 8550)? Format the cell with a custom format 00000 and you will always see 5 digits. Hi Fred! In addition to Anon's 00000 custom format suggestion, there's also two Zip code formats under Format > Cells > Number > Special. Plain vanilla "Zip...

: Delegation of setting Mailbox permissions...error
All, I have read the "Working with Active Directory Permissions in Microsoft Exchange 2003.doc" and used the specific snippets to delegate the creation of mailbox enabled user object in to a W2K3 AD/E2K3 SP1 environment. I don't have full control on the users objects nor have I delegated write all attributes on the user objects only a subset. Still I can change every attribute related to the exchange information, so far so good. The only problem I have is when setting the mailbox security. Access denied: Facility: LDAP Provider ID no: 80070005 Microsoft Active Directory -...

setting up Outlook #6
How do I set up outlook to send and recieve emails when I have AOL? Sxybutterfly <Sxybutterfly@discussions.microsoft.com> wrote: > How do I set up outlook to send and recieve emails when I have AOL? AOL has instructions on how to do this. -- Brian Tillman ...

How do I set up foot page to print out the computer's name
How do I set up foot page to print out the computer's name Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "Computer name: " & Environ("Computername") End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH RP (remove nothere from the email address if mailing direct) "Bee" <Bee@...

XP Forgets Display Settings After Restart
Hi, I have dual displays at my computer and it has recently started "forgetting" the display settings after I restart. Upon restarting once, only one monitor will come up with a signal and I can't get it to output to the other monitor. If I restart a second time, both monitors will have a signal but it has the wrong montior set up as the primary monitor. What is supposed to be my second monitor (the one w/ my desktop extended onto it) has my desktop icons and an extra toolbar that I use. It's also oriented on the wrong side of what is supposed to be my primary ...