Very simple, I have a datagrid on a windows form. I load some rows in it.
I click a column header and it sorts ascending. I click it again it sorts
descending. This is great, but what I want to do is after the sort, I want
to know what row is now the "selected" row. I want to do this so I can
update some stuff on the form that correlates to this row. This does not
seem so easy...please advise.
Thanks,
Ben 6 1981
Hi,
Use the currencymanager to get the row number. If your datagrid is
bound to a dataset.table use the dataset.table.defaultview to get the
row. http://www.onteorasoftware.com/downl...redcolumns.zip
Ken
--------------------
"Becker" <be*@benbecker.net> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl: Very simple, I have a datagrid on a windows form. I load some rows in it.
I click a column header and it sorts ascending. I click it again it sorts
descending. This is great, but what I want to do is after the sort, I want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does not
seem so easy...please advise.
Thanks, Ben
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus ( http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Ken,
I'm confused. The example you pointed me to does the exact same thing I've
got now. When you click, it shows you the name of the current row pre-sort,
but when you let up and it sorts, it doesn't show the name of the post-sort
record that is selected.
What I want is after the sort, the row that is selected, I want to know it's
data values, not the record that used to be there before the sort. Make
sense? I've looked at an answer on syncfusion, and it uses the bindcast
thing, but it doesn't seem to work. I've not seen any working examples of
this. Any ideas?
Thanks,
Ben
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hi,
Use the currencymanager to get the row number. If your datagrid is bound to a dataset.table use the dataset.table.defaultview to get the row.
http://www.onteorasoftware.com/downl...redcolumns.zip
Ken --------------------
"Becker" <be*@benbecker.net> wrote in message news:#I**************@TK2MSFTNGP10.phx.gbl: Very simple, I have a datagrid on a windows form. I load some rows in
it. I click a column header and it sorts ascending. I click it again it
sorts descending. This is great, but what I want to do is after the sort, I want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does
not seem so easy...please advise.
Thanks, Ben
-- Outgoing mail is certified Virus Free. Checked by AVG Anti-Virus (http://www.grisoft.com). Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Hi Ben,
The first question, did you use the dataview as the datasource.
That solves the sort problem mostly, and than use the dataview as the
connection to your tables
I hope this helps?
(And when not reply)
Cor Very simple, I have a datagrid on a windows form. I load some rows in it. I click a column header and it sorts ascending. I click it again it sorts descending. This is great, but what I want to do is after the sort, I
want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does not seem so easy...please advise.
Thanks, Ben
Hi Ben,
The first question, did you use the dataview as the datasource.
That solves the sort problem mostly, and than use the dataview as the
connection to your tables
I hope this helps?
(And when not reply)
Cor Very simple, I have a datagrid on a windows form. I load some rows in it. I click a column header and it sorts ascending. I click it again it sorts descending. This is great, but what I want to do is after the sort, I
want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does not seem so easy...please advise.
Thanks, Ben
Hi,
Made a few changes I added a handler to the dataview list changed
event.
Changes to form load
DataGrid1.DataSource = ds.Tables("Categories")
DataGrid2.DataSource = ds.Tables("Employees")
AddHandler ds.Tables("Categories").DefaultView.ListChanged,
AddressOf OnListChanged
Other changes
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(e.X, e.Y)
If hti.Type = DataGrid.HitTestType.ColumnHeader Then
'
' Just sorted
'
Trace.WriteLine(DataGrid1.TableStyles(0).GridColum nStyles.Item(hti.Column).MappingName)
End If
End Sub
Protected Sub OnListChanged(ByVal sender As Object, ByVal args As
System.ComponentModel.ListChangedEventArgs)
GetName()
End Sub
Private Sub GetName()
Dim cm As CurrencyManager =
CType(Me.BindingContext(DataGrid1.DataSource), _
CurrencyManager)
Dim drv As DataRowView
drv = ds.Tables("Categories").DefaultView.Item(cm.Positi on)
Trace.WriteLine(drv.Item("CategoryName").ToString)
End Sub
Ken
----------------------
"Becker" <be*@benbecker.net> wrote in message
news:#I**************@TK2MSFTNGP11.phx.gbl: Ken,
I'm confused. The example you pointed me to does the exact same thing I've got now. When you click, it shows you the name of the current row pre-sort, but when you let up and it sorts, it doesn't show the name of the post-sort record that is selected.
What I want is after the sort, the row that is selected, I want to know it's data values, not the record that used to be there before the sort. Make
sense? I've looked at an answer on syncfusion, and it uses the bindcast
thing, but it doesn't seem to work. I've not seen any working examples of
this. Any ideas?
Thanks, Ben
"Ken Tucker [MVP]" <HYPERLINK "mailto:vb***@bellsouth.net"vb***@bellsouth.ne t> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
Use the currencymanager to get the row number. If your datagrid is bound to a dataset.table use the dataset.table.defaultview to get the row.
HYPERLINK "http://www.onteorasoftware.com/downloads/coloredcolumns.zip"http://www.onte orasoftware.com/downloads/coloredcolumns.zip
Ken --------------------
"Becker" <HYPERLINK "mailto:be*@benbecker.net"be*@benbecker.net> wrote in message news:#I**************@TK2MSFTNGP10.phx.gbl:
Very simple, I have a datagrid on a windows form. I load some rows in it.
I click a column header and it sorts ascending. I click it again it sorts
descending. This is great, but what I want to do is after the sort, I want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does not
seem so easy...please advise.
Thanks, Ben
-- Outgoing mail is certified Virus Free. Checked by AVG Anti-Virus (http://www.grisoft.com). Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus ( http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004
No, thats probably my problem. I use datasource = ds.tables("table")
I will try the ideas I've seen here.
Thanks!
Ben
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi Ben,
The first question, did you use the dataview as the datasource.
That solves the sort problem mostly, and than use the dataview as the connection to your tables
I hope this helps? (And when not reply)
Cor
Very simple, I have a datagrid on a windows form. I load some rows in
it. I click a column header and it sorts ascending. I click it again it
sorts descending. This is great, but what I want to do is after the sort, I want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does
not seem so easy...please advise.
Thanks, Ben
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: aaa |
last post by:
Hi
I am trying to create a read-only DataGrid that would always have
current row selected. Currently, I am using method:
public void SelectDataGridRow(DataGrid dg)
{
if (dg.CurrentRowIndex >...
|
by: VMI |
last post by:
Hi,
I have a Windows datagrid that's attached to a filled datatable. The grid
also has a tablestyle. Since the data from the grid comes from a
datatatable, how can I retrieve the data from a...
|
by: Steve B. |
last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's
reflect the contents of the grid cells.
Sorting of columns (both thru VS and programmatically) work fine except,
when the...
|
by: Jeremy |
last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
|
by: Jim |
last post by:
Hello,
I am creating a windows form application using vb.net 2003 which displays
data in a datagrid, and then, if the user wants, I produce a nicely
formatted crystal report of the data.
The...
|
by: Gene Hubert |
last post by:
I'm using DataTable.ImportRow to move data from one datatable to
another...
Dim dt, dtTarget As DataTable
Dim dr As DataRow
dt = DirectCast(Me.DataSource, DataTable)
dtTarget = dt.Clone...
|
by: stojilcoviz |
last post by:
I've a datagrid whose datasource is an arraylist object. The arraylist
holds many instances of a specific class.
I've two questions about this:
1 - Is there a way by which I can obtain a...
|
by: JohnR |
last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a
datagridtablestyle defined. I use the datagridtablestyle to change the
order of the columns (so they can be different than...
|
by: Ryan Liu |
last post by:
Can someone give a sample to prevent a row from being deleted in a
datatable?
I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work.
I need verify if there other data...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |