Hi,
How to get Current Item Position(row and column numbers) when a user click on particular cell in wxDataViewCtrl??
thanks,..
Position of an item in wxDataViewCtrl
-
- Experienced Solver
- Posts: 57
- Joined: Wed Feb 25, 2015 2:09 pm
- Location: Chennai, India
Position of an item in wxDataViewCtrl
Got a Problem???..No worry..Focus on Solution not on Problem
Re: Position of an item in wxDataViewCtrl
Either through methods of wxDataViewEvent ( GetItem() & GetColumn() )
http://docs.wxwidgets.org/trunk/classwx ... event.html
Or wxDataViewCtrl::HitTest()
http://docs.wxwidgets.org/trunk/classwx ... 6fff16eb0c
http://docs.wxwidgets.org/trunk/classwx ... event.html
Or wxDataViewCtrl::HitTest()
http://docs.wxwidgets.org/trunk/classwx ... 6fff16eb0c
Use the source, Luke!
-
- Experienced Solver
- Posts: 57
- Joined: Wed Feb 25, 2015 2:09 pm
- Location: Chennai, India
Re: Position of an item in wxDataViewCtrl
I got Column number from GetColumn(), but how to get Row number after getting GetItem()??
Got a Problem???..No worry..Focus on Solution not on Problem
-
- Experienced Solver
- Posts: 57
- Joined: Wed Feb 25, 2015 2:09 pm
- Location: Chennai, India
Re: Position of an item in wxDataViewCtrl
nandakishore wrote:I got Column number from GetColumn(), but how to get Row number after getting GetItem()??
Got a Problem???..No worry..Focus on Solution not on Problem
Re: Position of an item in wxDataViewCtrl
Isn't the item usually the one you need? Anyway, i haven't found a public method that returns the row for an item.
Use the source, Luke!
-
- Experienced Solver
- Posts: 57
- Joined: Wed Feb 25, 2015 2:09 pm
- Location: Chennai, India
Re: Position of an item in wxDataViewCtrl
Actually i want to display the status whenever user clicks on particular cell. so i need row and column numbers..
Got a Problem???..No worry..Focus on Solution not on Problem
Re: Position of an item in wxDataViewCtrl
Are you using wxDataViewCtrl or wxDataViewListCtrl? In the latter case, there is wxDataViewListCtrl::ItemToRow()
http://docs.wxwidgets.org/trunk/classwx ... ad30be241f
http://docs.wxwidgets.org/trunk/classwx ... ad30be241f
Use the source, Luke!
Re: Position of an item in wxDataViewCtrl
I am relatively new to using wxDataViewCtrl and its descendants so I can't be sure that the following is totally correct.
I think the reason there is no "GetRow" option in the base wxDataViewCtrl is because the control is capable of displaying information in a tree format where "row" may not have a specific meaning.
If you want to display data in a table format which has rows of similarly presented data, I would suggest using wxDataViewIndexListModel and associating that model with your wxDataViewCtrl. You can then use mouse events generated by the control to get the corresponding row in the model.
For example:
This is essentially the same as DoubleMax is saying, however I have suggested to use the basic wxDataViewCtrl and associate it with a model (rather than use the wxDataViewListCtrl directly) because:
I think the reason there is no "GetRow" option in the base wxDataViewCtrl is because the control is capable of displaying information in a tree format where "row" may not have a specific meaning.
If you want to display data in a table format which has rows of similarly presented data, I would suggest using wxDataViewIndexListModel and associating that model with your wxDataViewCtrl. You can then use mouse events generated by the control to get the corresponding row in the model.
For example:
Code: Select all
void SomeGUIClass::OnGridLeftDclick(wxDataViewEvent& event)
{
unsigned int row = pMyIndexListModel->GetRow (event.GetItem());
// ... whatever you want to do with the row
}
- It gives you much greater flexibility over the display of the data in different columns (this is why I have become a fan of wxDataViewCtrls recently )
- One of the main wxWidgets devs told me that wxDataViewListCtrl is "broken" (https://groups.google.com/forum/?fromgr ... k8E677Yk6I). However I am not sure if this means the that the control is broken or the concept of a list model used by the control
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.