473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How do I get the selected item from a datagrid

How do I get the selected item from a datagrid?
Thanks
Nov 20 '05 #1
5 6247
Hi Tony,

I assume a VB.net datagrid however there are two with totally different
behaviour the webform one and the windowform one.

Mostly after a while people recognize they are answering for the wrong one,
so which is it?

Cor
How do I get the selected item from a datagrid?
Thanks

Nov 20 '05 #2
Hi Tony,

I assume a VB.net datagrid however there are two with totally different
behaviour the webform one and the windowform one.

Mostly after a while people recognize they are answering for the wrong one,
so which is it?

Cor
How do I get the selected item from a datagrid?
Thanks

Nov 20 '05 #3
The Window for one...
Whilst asking - how do I set a column width on the grid ?
Thanks

"Cor Ligthert" wrote:
Hi Tony,

I assume a VB.net datagrid however there are two with totally different
behaviour the webform one and the windowform one.

Mostly after a while people recognize they are answering for the wrong one,
so which is it?

Cor
How do I get the selected item from a datagrid?
Thanks


Nov 20 '05 #4
The Window for one...
Whilst asking - how do I set a column width on the grid ?
Thanks

"Cor Ligthert" wrote:
Hi Tony,

I assume a VB.net datagrid however there are two with totally different
behaviour the webform one and the windowform one.

Mostly after a while people recognize they are answering for the wrong one,
so which is it?

Cor
How do I get the selected item from a datagrid?
Thanks


Nov 20 '05 #5
Hi Tony,

I did make this morning this sample here beneath, there should be the
answers on your questions in and as well a lot of your next answers on your
questions,

I hope this helps?

Cor

\\\Needs one datagrid and one button on a form
Private ds As New DataSet
Private WithEvents cma As CurrencyManager
Private dv As DataView
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "Click me to show"
Dim dt As New DataTable("MyTable")
ds.Tables.Add(dt)
dt.Columns.Add("Streets")
DataGrid1.AllowSorting = False
Dim mystring() As String = {"Highfield Road", _
"Abbey(Close)", "Bower(Way)", "Roadway To Hell"}
For i As Integer = 0 To mystring.Length - 1
Dim dr As DataRow = dt.NewRow
dr(0) = mystring(i)
dt.Rows.Add(dr)
Next
dv = New DataView(ds.Tables(0))
cma = DirectCast(BindingContext(dv), CurrencyManager)
DataGrid1.DataSource = dv
Dim ts As New DataGridTableStyle
ts.MappingName = "MyTable"
Dim column As New DataGridTextBoxColumn
column.TextBox.MaxLength = 50
column.MappingName = "Streets"
column.HeaderText = "My streets"
column.Width = 150
column.NullText = ""
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show(dv(cma.Position) _
(DataGrid1.CurrentCell.ColumnNumber).ToString)
End Sub
///
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: R Agam | last post by:
How do I get the selected Rows index in the DataGrid? Thanks, Ronen
4
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
4
by: rodchar | last post by:
hey all, when you first load a page with a datagrid item on it, is the first record always selected by default? if so, is there a way to have it where nothing is selected by default? thanks,...
3
by: xianxian | last post by:
Hi guys, I'm having trouble getting my Datagrid to display according to Checkboxes checked values. On my Checkboxes, I have 5 values :- 1) Apartment/Condo 2) Executive Condo 3) Detached 4)...
5
by: Samy | last post by:
Hi There, I have a label in a datagrid which I make it a input type = radio in ItemDataBound so that radio buttons are shown in the datagrid. This is how I have it... ASPX... <asp:Label...
1
by: tupolev | last post by:
I have successfully created a datagrid with a combobox added in a column of the datagrid, I also have written an event that works when you select an other item in the combobox. Know: how can I...
3
by: DC | last post by:
Hi all (once again), I've populated a datagrid with an arraylist of objects of this class i've created. How can I get the select object in the datagrid? TIA, DC
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.