I am referencing a datagrid item like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), 0)
The Item Number is in the first column; column 0. It works fine
except this is not a very good programming practice. What if someday
someone decides to move the "item number" column to the fourth or
fifth position?
I'm looking for a way to reference the column index using the column
name, so I could write the statement something like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(),
grdItems.Column ("Item Number"))
That way it doesn't matter what position the "Item Number" column is
in, the line will still work. Is there a way to do this?
Thanks,
Dominic Isaia di****@earthlin k.net 8 3935
Are you trying to access the contents of the currently active cell? If so,
would this work for you?
grdItems.Item(g rdItems.Current Cell.RowNumber,
grdItems.Curren tCell.ColumnNum ber)
hope this helps..
Imran.
"Moondog" <di****@earthli nk.net> wrote in message
news:42******** *************** **@posting.goog le.com... I am referencing a datagrid item like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), 0)
The Item Number is in the first column; column 0. It works fine except this is not a very good programming practice. What if someday someone decides to move the "item number" column to the fourth or fifth position?
I'm looking for a way to reference the column index using the column name, so I could write the statement something like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), grdItems.Column ("Item Number"))
That way it doesn't matter what position the "Item Number" column is in, the line will still work. Is there a way to do this?
Thanks, Dominic Isaia di****@earthlin k.net
There is no direct way to access the column through name.. You could through
the dataset that is bound to the column, i.e if you are using bound data
mode. I am not sure if you do... Please refer to the following and see if
you can find anything http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
VJ
"Moondog" <di****@earthli nk.net> wrote in message
news:42******** *************** **@posting.goog le.com... I am referencing a datagrid item like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), 0)
The Item Number is in the first column; column 0. It works fine except this is not a very good programming practice. What if someday someone decides to move the "item number" column to the fourth or fifth position?
I'm looking for a way to reference the column index using the column name, so I could write the statement something like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), grdItems.Column ("Item Number"))
That way it doesn't matter what position the "Item Number" column is in, the line will still work. Is there a way to do this?
Thanks, Dominic Isaia di****@earthlin k.net
Moondog,
In addition to the others, it is a better way to access a datagrid through
its datasource, where is the it even better to use for that to show the
dataview.
Otherwise you can get problems as well when there the users sorts.
something as rougly typed in this message
\\\
dim dv as new dataview(mydata set.table)
dg.datasource = dv
dim cma as new currencymanger
cma = directcast(bind ingcontext(dv), currencymanager )
///
\\\
In a button item
cma.endcurrente dit
whatIwant = dv(cma.postitio n)("mycolumn")
///
I hope this helps?
Cor I am referencing a datagrid item like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), 0)
The Item Number is in the first column; column 0. It works fine except this is not a very good programming practice. What if someday someone decides to move the "item number" column to the fourth or fifth position?
I'm looking for a way to reference the column index using the column name, so I could write the statement something like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), grdItems.Column ("Item Number"))
That way it doesn't matter what position the "Item Number" column is in, the line will still work. Is there a way to do this?
Thanks, Dominic Isaia di****@earthlin k.net
I had the same issue with the datagrid. See below for what I did...
You call BuildNumNameXre fGrid after you've got columnstyles added to
the grid and anytime the set of columnstyles changes (I think I need
do a hashtable.clear to handle changing the set of visible columns as
I haven't tried that yet). Then call NumFromNameGrid with the column
name to get the column number.
I have a similar set of methods that handles all columns in the
underlying datatable (not just the visible columns). This code
resides in an object that holds configuration information for how the
grid is set up (e.g. number and type of columns, column names, etc.)
Gene H.
Private Shared NumNameXrefGrid As New Hashtable
'handles visible columns in grid
Public Shared Sub BuildNumNameXre fGrid(ByVal dg As DataGrid)
Dim i As Integer
Dim dgtbc As DataGridColumnS tyle
For Each dgtbc In dg.TableStyles( 0).GridColumnSt yles
NumNameXrefGrid .Add(dgtbc.Mapp ingName, i)
i += 1
Next
End Sub
Public Shared Function NumFromNameGrid (ByVal name As String)
As Integer
Return CInt(NumNameXre fGrid(name))
End Function di****@earthlin k.net (Moondog) wrote in message news:<42******* *************** ***@posting.goo gle.com>... I am referencing a datagrid item like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), 0)
The Item Number is in the first column; column 0. It works fine except this is not a very good programming practice. What if someday someone decides to move the "item number" column to the fourth or fifth position?
I'm looking for a way to reference the column index using the column name, so I could write the statement something like this:
strItemNo = grdItems.Item(g rdItems.Current RowIndex(), grdItems.Column ("Item Number"))
That way it doesn't matter what position the "Item Number" column is in, the line will still work. Is there a way to do this?
Thanks, Dominic Isaia di****@earthlin k.net
I guess there's no simple solution.
Imran: No, I'm trying to get the column number from a column name in
the datagrid.
VJ and Cor: I guess this is the only way to do it. I had made those
datasets temporary and local to my fillgrid function, so maybe I
should bump them up to global.
Thanks for your input guys, di****@earthlin k.net
Moondog, VJ and Cor: I guess this is the only way to do it. I had made those datasets temporary and local to my fillgrid function, so maybe I should bump them up to global.
When you want.
You can as well use when you want
directcast(data grid.dataview,D ataview).etc any property or method
Andof course the type of the datasource you use, it can as well be datatable
or any other you are using.
I hope this gives some ideas?
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Webgour |
last post by:
Hi,
I'm tring to add a column to a datagrid with a linkbutton as header that can
be used to sort the column. The column and the linkbutton are added
programmatically (see below). However the problem is that when you click the
added column header it doesn't trigger the sort.
The code :
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
|
by: PeterZ |
last post by:
Hi,
In a running C# app with a datagrid control I select all rows in the
dataGrid using CTRL-A, I then paste into some other app like notepad or Word
but the column headings get left off.
Is there any way of including column headings when copying/pasting from a
running datagrid to notepad? At this stage it looks like I have to write my
own code but would rather not if someone knows how to do it.
|
by: Mike L |
last post by:
This is for a Win form, in C# 2005.
I want to load a datagrid, make some columns width 0, and then clean out the
record I added.
I get the error message, ""Index was out of range. Must be non-negative and
less than the size of the collection. Parameter name: index""
I have tried, -1,0,1,2 for the index, and I get the same error message on
each try.
|
by: Amber |
last post by:
There are times when you will need to highlight or otherwise modify
the contents of a particular DataGrid row-column value based upon the
value in the column. In this example we will select the CompanyName,
ContactName, and ContactTitle columns from the Customers table in the
Northwind database. Whenever the value of ContactTitle equals "Owner"
we will change the font color to red.
We can do this by using an ItemTemplate where we have...
|
by: Jack Black |
last post by:
Hi, all!
I'm trying to build a hyperlink column in a DataGrid whose textField
is one column in the query, but whose URL needs to dynamically contain
the data from another.
For example, I want to display a book title (column = "Title"), but
the URL needs to be:
myPage.aspx?book=ISBN (where ISBN is a column name)
| |
by: Raed Sawalha |
last post by:
i have datagrid , I added a bound column and I need to map it with two data
fields ...is this possible?
<asp:datagrid id=dgInbox runat="server" EnableViewState="False"
AutoGenerateColumns="False" AllowSorting="True" Width="100%">
<ItemStyle Wrap="False" BorderWidth="11px" BorderStyle="Solid"
CssClass="tableCell"></ItemStyle>
<HeaderStyle Height="26px" CssClass="tableHeaderCell"></HeaderStyle>
<Columns>
<asp:BoundColumn...
|
by: Benny Raymond |
last post by:
reply to: benny@pocketrocks.com if possible:
I'm trying to set up a hierarchy system in this database where each row
can be related to a previous row. The problem is that when I go to
addTreeRow, it doesn't allow me to use Convert.DBNull for the childof
column, even though I have nilable set to true. (All parent nodes have
to be set to null, since they are not the child of any other row...
especially the very first row, which will have...
|
by: Javier |
last post by:
Hi Everyone,
I have a dynamic checkbox in a datagrid that uses the ITemplate interface
and has the checkchanged event wired up. When the checkbox is checked, the
event
event handler that handles the event gets called, however when it is
unchecked, it does not fire. Is this by design, or is something else that
is going on? Thanks!!.
This message was originally posted by marian@discussions.microsoft.com, but
|
by: TPhelps |
last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable
datagrid that works.
I want to change one of the columns to a hyperlink. The examples I find use
a bound column. I can get this to work; however, the column header on the
datagrid is not a link/sortable.
What am I missing?
Thanks in advance.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |