Print Page | Close Window

Getting the value of column 1 when doubleclicking

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=7175
Printed Date: 17 July 2025 at 10:12am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Getting the value of column 1 when doubleclicking
Posted By: Soren
Subject: Getting the value of column 1 when doubleclicking
Date Posted: 18 May 2007 at 10:56am
Hi.
 
I use a reportControl to read customers from my MySQL-database.
 
When I double-click a certain row, I would like to get the customer-number which is placed i the first column.
 
I think I shall use my CustList.RowDblClick, or am I wrong?
 
 



Replies:
Posted By: Zach
Date Posted: 18 May 2007 at 12:36pm
RowDblClick event
 
 
Then its as easy as
 
msgbox Row.Record(0).Value


Posted By: Soren
Date Posted: 18 May 2007 at 4:16pm
Hi Zach.
 
Thank You for your reply, but it does not work.
 
When I use your code, I get the row number and not the content.


Posted By: moe188
Date Posted: 18 May 2007 at 5:51pm
hi,
try this with reprotcontrol selection changed or rowdoublclick
        If Not wndview.FocusedRow.GroupRow Then
            CustomeNumber = wndview.FocusedRow.Record(Col1).Value
        end if
I hope that will work for you
 


Posted By: Soren
Date Posted: 18 May 2007 at 6:06pm
I think there is something wrong.
I've tried
       If Not wndview.FocusedRow.GroupRow Then
            CustomeNumber = wndview.FocusedRow.Record(Col1).Value
        end if
 
and it returns the row number
 
And if I do this:
       If Not wndview.FocusedRow.GroupRow Then
            CustomeNumber = wndview.FocusedRow.Record(SOME_RUBBISH).Value
        end if
 
the row number is returned too.
 
Could there be som settings missing in the report control?


Posted By: Zach
Date Posted: 18 May 2007 at 7:18pm
Dont know what to tell you..
 
 
I have a RowDblClick even that looksl ike this... in VB6 ... and works perfectly
 
Private Sub Data_RowDblClick(ByVal Row As XtremeReportControl.IReportRow, _
                             ByVal Item As XtremeReportControl.IReportRecordItem)
 
    MsgBox Row.Record(4).Value
 
End Sub
 
 
You can also try Row.Record(4).Caption ... depending on what you are doing... you may need to do that.


Posted By: Soren
Date Posted: 18 May 2007 at 7:35pm
Hi Zack
 
This is what I do:
 
First, I create the headers
    frmKontakter.CustomerList.Columns.Add 0, "Customer Number", 25, True
    frmKontakter.CustomerList.Columns.Column(0).Groupable = False
    frmKontakter.CustomerList.Columns.Add 1, "Company name", 100, True
    frmKontakter.CustomerList.Columns.Add 2, "Address", 100, True
    frmKontakter.CustomerList.Columns.Add 3, "ZIP", 50, True
Then I add the data:
 
aCount = rsTable.RecordCount
rsTable.MoveFirst
a = 0
While a < aCount
        Set Record = CustomerList.Records.Add
        Set Item = Record.AddItem(a)
        Item.Format = rsTable.Fields!CustomerNUmber
        Set Item = Record.AddItem(Str)
        Item.Format = rsTable.Fields!CompanyName
        Set Item = Record.AddItem(Str)
        Item.Format = rsTable.Fields!Address
        Set Item = Record.AddItem(Str)
        Item.Format = rsTable.Fields!ZIP

        a = a + 1
        rsTable.MoveNext
Wend
CustomerList.Populate


Posted By: moe188
Date Posted: 18 May 2007 at 8:21pm
Hi Zac
I used the same code with the SelectionChanged events to get the value of the first column with no problems. then when I double click on reportcontrol (RowDblClick events), I check for the value of the first column, if the value is empty I don't do nothing otherwise I do whatever I want to do base on the value of column 1.
good luck.
 


Posted By: Zach
Date Posted: 19 May 2007 at 12:27am
Originally posted by Soren Soren wrote:

Hi Zack
 
This is what I do:
 
First, I create the headers
    frmKontakter.CustomerList.Columns.Add 0, "Customer Number", 25, True
    frmKontakter.CustomerList.Columns.Column(0).Groupable = False
    frmKontakter.CustomerList.Columns.Add 1, "Company name", 100, True
    frmKontakter.CustomerList.Columns.Add 2, "Address", 100, True
    frmKontakter.CustomerList.Columns.Add 3, "ZIP", 50, True
Then I add the data:
 
aCount = rsTable.RecordCount
rsTable.MoveFirst
a = 0
While a < aCount
        Set Record = CustomerList.Records.Add
        Set Item = Record.AddItem(a)
        Item.Format = rsTable.Fields!CustomerNUmber
        Set Item = Record.AddItem(Str)
        Item.Format = rsTable.Fields!CompanyName
        Set Item = Record.AddItem(Str)
        Item.Format = rsTable.Fields!Address
        Set Item = Record.AddItem(Str)
        Item.Format = rsTable.Fields!ZIP

        a = a + 1
        rsTable.MoveNext
Wend
CustomerList.Populate
 
 
If that is in someway is close to your exact code... uh... what did you expect?
 
You are placing a count into the first column?
 
I also assume you define a value for Str elsewhere.. but this:
 
 
        Set Item = Record.AddItem(a)
 
 
listed like that .. when the others are listed like:
 
 
        Set Item = Record.AddItem(Str)
 
 
 
Would as I said... make me think that you are assigning the value to Str elsewhere... and just used that for filler... but the first one.. it really looks like you put in "a" there... or its value anyway... which would make it so that when you double click on it... you are going to get what looks like a row number...
 
... if you post the actual code... from the select statement to the end of the loop of the results... I can probably have a better clue what is wrong...


Posted By: Zach
Date Posted: 19 May 2007 at 12:33am
I never use the format part of the Report Control... but I just realized.. you did just post your actual code :)
 
You are formatting each cell to look like your result... hum... interesting... might be an interesting trick to use sometime... but... uh.. why?
 
 
 
 
        Set Record = CustomerList.Records.Add
        Set Item = Record.AddItem(rsTable.Fields!CustomerNUmber)
        Set Item = Record.AddItem(rsTable.Fields!CompanyName)
        Set Item = Record.AddItem(rsTable.Fields!Address)
        Set Item = Record.AddItem(rsTable.Fields!ZIP)
 
... That I think will get you what you want... sorry I missed that the first time... as I said.. I do not use the format property and I have never used the Microsoft way of pulling in fields from a table so I just ignored that part in my mind at first


Posted By: Soren
Date Posted: 19 May 2007 at 4:26am
Hi again Zach
 
Thank you very much for your help.
You really got me right on track.
 
At first, I did:
      Set Item = Record.AddItem(rsTable.Fields!CustomerNUmber)
 
but the List stayed empty
 
Then I started thinking about what you said about formatting.
 
So, now I do this:
   Set Item = Record.AddItem(CInt(rsTable.Fields!CustomerNUmber))
   Set Item = Record.AddItem(CStr(rsTable.Fields!CompanyName))
 
 
And everything is pure happiness


Posted By: Zach
Date Posted: 19 May 2007 at 3:40pm
Cool... I actually thought about adding CInt, CStr... but then just didnt.. my bad :(
 
 


Posted By: Baldur
Date Posted: 30 October 2007 at 6:06am
You don't need the CInt/CStr-Conversion, because you put the Fieldobject to the Item and not the default-property.
 
Expand your Code with
Set Item = Record.AddItem(rsTable.Fields!CustomerNUmber.Value)
 
This save time and also the content-type stays there (eg. Date/Str/Double/int/...)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net