473,503 Members | 5,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6257
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
35934
by: R Agam | last post by:
How do I get the selected Rows index in the DataGrid? Thanks, Ronen
4
2093
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
5384
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
1944
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
1577
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
1927
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
3174
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
1492
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
5836
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
3666
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
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.