Getting the value of column 1 when doubleclicking |
Post Reply |
Author | |
Soren
Newbie Joined: 09 May 2007 Location: Denmark Status: Offline Points: 13 |
Post Options
Thanks(0)
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?
|
|
Zach
Groupie Joined: 19 July 2006 Status: Offline Points: 62 |
Post Options
Thanks(0)
|
RowDblClick event
Then its as easy as
msgbox Row.Record(0).Value
|
|
Soren
Newbie Joined: 09 May 2007 Location: Denmark Status: Offline Points: 13 |
Post Options
Thanks(0)
|
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.
|
|
moe188
Senior Member Joined: 27 March 2006 Status: Offline Points: 220 |
Post Options
Thanks(0)
|
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
|
|
Soren
Newbie Joined: 09 May 2007 Location: Denmark Status: Offline Points: 13 |
Post Options
Thanks(0)
|
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?
|
|
Zach
Groupie Joined: 19 July 2006 Status: Offline Points: 62 |
Post Options
Thanks(0)
|
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.
|
|
Soren
Newbie Joined: 09 May 2007 Location: Denmark Status: Offline Points: 13 |
Post Options
Thanks(0)
|
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 |
|
moe188
Senior Member Joined: 27 March 2006 Status: Offline Points: 220 |
Post Options
Thanks(0)
|
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.
|
|
Zach
Groupie Joined: 19 July 2006 Status: Offline Points: 62 |
Post Options
Thanks(0)
|
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...
|
|
Zach
Groupie Joined: 19 July 2006 Status: Offline Points: 62 |
Post Options
Thanks(0)
|
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 |
|
Soren
Newbie Joined: 09 May 2007 Location: Denmark Status: Offline Points: 13 |
Post Options
Thanks(0)
|
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
|
|
Zach
Groupie Joined: 19 July 2006 Status: Offline Points: 62 |
Post Options
Thanks(0)
|
Cool... I actually thought about adding CInt, CStr... but then just didnt.. my bad :(
|
|
Baldur
Senior Member Joined: 22 November 2006 Location: Germany Status: Offline Points: 244 |
Post Options
Thanks(0)
|
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/...)
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |