473,657 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid Questions

I know how to do this stuff so easily in VB6.........

3 questions.

I have loaded a grid by binding it to a dataset. All is well with that.

1) How do I retrieve the value of a column when a user clicks on a row? I
use a Sheriden grid in VB6 and would do something like:

MyString = MyGrid.Columns( n).Text

2) Some of the columns I'm pulling are datetime columns that have not been
set yet. I am getting (null) in the column. How do I prevent that and just
display nothing?

3) I have a column that is a bit field. Before I applied any formatting,
the column came back as a greyed checkbox. The value at the time was
(null). Now, with formatting and values, I'm getting True or False. I want
a checked or unchecked checkbox. How do I do that?

Thanks in advance.

Nov 20 '05 #1
4 1092
Hi,

1) If you have add a tablestyle to your datagrid
Dim dc As DataGridCell = DataGrid1.Curre ntCell

If DataGrid1.Table Styles.Count > 0 Then

MessageBox.Show (DataGrid1.Tabl eStyles(0).Grid ColumnStyles.It em(dc.ColumnNum ber).HeaderText )

End If
2) Add a tablestyle to your datagrid. The datagridtextbox column has
a nulltext property set this to what you want it to display instead of
(null).

3) Set a default value for your datacolumn to prevent the grayed
checkbox.
ds.Tables("Prod ucts").Columns( "Discontinued") .DefaultValue = False

Ken

---------------------------

"Ed Bick" <no******@comca st.net> wrote in message
news:du******** ************@co mcast.com...
I know how to do this stuff so easily in VB6.........

3 questions.

I have loaded a grid by binding it to a dataset. All is well with that.

1) How do I retrieve the value of a column when a user clicks on a row? I
use a Sheriden grid in VB6 and would do something like:

MyString = MyGrid.Columns( n).Text

2) Some of the columns I'm pulling are datetime columns that have not been
set yet. I am getting (null) in the column. How do I prevent that and
just
display nothing?

3) I have a column that is a bit field. Before I applied any formatting,
the column came back as a greyed checkbox. The value at the time was
(null). Now, with formatting and values, I'm getting True or False. I
want
a checked or unchecked checkbox. How do I do that?

Thanks in advance.

Nov 20 '05 #2
Ken,

Thanks for your help.

on #1, what I am returning with this code is the column header text. I am
looking to get the value on the specific row in the grid.

on #3, I guess I wasn't clear enough. I'm not necessarily aiming at
preventing the greyed checkbox. I want checkboxes. So, if my value coming
back from the DB is a 0, I want an unchecked checkbox. If it's 1, I want a
checked checkbox. I have the grid as ReadOnly, so the greyed or not greyed
part doesn't matter so much.

Thanks in advance, again.

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:eg******** ******@tk2msftn gp13.phx.gbl...
Hi,

1) If you have add a tablestyle to your datagrid
Dim dc As DataGridCell = DataGrid1.Curre ntCell

If DataGrid1.Table Styles.Count > 0 Then

MessageBox.Show (DataGrid1.Tabl eStyles(0).Grid ColumnStyles.It em(dc.ColumnNum b
er).HeaderText)
End If
2) Add a tablestyle to your datagrid. The datagridtextbox column has a nulltext property set this to what you want it to display instead of
(null).

3) Set a default value for your datacolumn to prevent the grayed
checkbox.
ds.Tables("Prod ucts").Columns( "Discontinued") .DefaultValue = False

Ken

---------------------------

"Ed Bick" <no******@comca st.net> wrote in message
news:du******** ************@co mcast.com...
I know how to do this stuff so easily in VB6.........

3 questions.

I have loaded a grid by binding it to a dataset. All is well with that.

1) How do I retrieve the value of a column when a user clicks on a row? I use a Sheriden grid in VB6 and would do something like:

MyString = MyGrid.Columns( n).Text

2) Some of the columns I'm pulling are datetime columns that have not been set yet. I am getting (null) in the column. How do I prevent that and
just
display nothing?

3) I have a column that is a bit field. Before I applied any formatting, the column came back as a greyed checkbox. The value at the time was
(null). Now, with formatting and values, I'm getting True or False. I
want
a checked or unchecked checkbox. How do I do that?

Thanks in advance.


Nov 20 '05 #3
Hi,

1)
Dim dc As DataGridCell = DataGrid1.Curre ntCell

MessageBox.Show (DataGrid1.Item (dc).ToString)

3) Have a look at the datagridboolcol umn's truevalue and falsevalue.

http://msdn.microsoft.com/library/de...valuetopic.asp

Ken

-----------------------

"Ed Bick" <no******@comca st.net> wrote in message
news:sK******** ************@co mcast.com...
Ken,

Thanks for your help.

on #1, what I am returning with this code is the column header text. I am
looking to get the value on the specific row in the grid.

on #3, I guess I wasn't clear enough. I'm not necessarily aiming at
preventing the greyed checkbox. I want checkboxes. So, if my value
coming
back from the DB is a 0, I want an unchecked checkbox. If it's 1, I want
a
checked checkbox. I have the grid as ReadOnly, so the greyed or not
greyed
part doesn't matter so much.

Thanks in advance, again.

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:eg******** ******@tk2msftn gp13.phx.gbl...
Hi,

1) If you have add a tablestyle to your datagrid
Dim dc As DataGridCell = DataGrid1.Curre ntCell

If DataGrid1.Table Styles.Count > 0 Then

MessageBox.Show (DataGrid1.Tabl eStyles(0).Grid ColumnStyles.It em(dc.ColumnNum b
er).HeaderText)

End If
2) Add a tablestyle to your datagrid. The datagridtextbox column

has
a nulltext property set this to what you want it to display instead of
(null).

3) Set a default value for your datacolumn to prevent the grayed
checkbox.
ds.Tables("Prod ucts").Columns( "Discontinued") .DefaultValue = False

Ken

---------------------------

"Ed Bick" <no******@comca st.net> wrote in message
news:du******** ************@co mcast.com...
>I know how to do this stuff so easily in VB6.........
>
> 3 questions.
>
> I have loaded a grid by binding it to a dataset. All is well with
> that.
>
> 1) How do I retrieve the value of a column when a user clicks on a row? I > use a Sheriden grid in VB6 and would do something like:
>
> MyString = MyGrid.Columns( n).Text
>
> 2) Some of the columns I'm pulling are datetime columns that have not been > set yet. I am getting (null) in the column. How do I prevent that and
> just
> display nothing?
>
> 3) I have a column that is a bit field. Before I applied any formatting, > the column came back as a greyed checkbox. The value at the time was
> (null). Now, with formatting and values, I'm getting True or False. I
> want
> a checked or unchecked checkbox. How do I do that?
>
> Thanks in advance.
>
>
>



Nov 20 '05 #4
That did the trick.

ONE more question, if you don't mind.

So, I've bound my grid to a dataset. Now a user clicks another control and
I want to wipe the grid clear and rebind it to the new dataset. My current
code is appended to the dataset. I can not seem to find the equivalent to
the clear method.

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:eX******** *****@tk2msftng p13.phx.gbl...
Hi,

1)
Dim dc As DataGridCell = DataGrid1.Curre ntCell

MessageBox.Show (DataGrid1.Item (dc).ToString)

3) Have a look at the datagridboolcol umn's truevalue and falsevalue.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwind owsformsdatagri dboolcolumnclas sfalsevaluetopi c.asp
Ken

-----------------------

"Ed Bick" <no******@comca st.net> wrote in message
news:sK******** ************@co mcast.com...
Ken,

Thanks for your help.

on #1, what I am returning with this code is the column header text. I am looking to get the value on the specific row in the grid.

on #3, I guess I wasn't clear enough. I'm not necessarily aiming at
preventing the greyed checkbox. I want checkboxes. So, if my value
coming
back from the DB is a 0, I want an unchecked checkbox. If it's 1, I want a
checked checkbox. I have the grid as ReadOnly, so the greyed or not
greyed
part doesn't matter so much.

Thanks in advance, again.

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:eg******** ******@tk2msftn gp13.phx.gbl...
Hi,

1) If you have add a tablestyle to your datagrid
Dim dc As DataGridCell = DataGrid1.Curre ntCell

If DataGrid1.Table Styles.Count > 0 Then

MessageBox.Show (DataGrid1.Tabl eStyles(0).Grid ColumnStyles.It em(dc.ColumnNum b er).HeaderText)

End If
2) Add a tablestyle to your datagrid. The datagridtextbox column
has
a nulltext property set this to what you want it to display instead of
(null).

3) Set a default value for your datacolumn to prevent the grayed
checkbox.
ds.Tables("Prod ucts").Columns( "Discontinued") .DefaultValue = False

Ken

---------------------------

"Ed Bick" <no******@comca st.net> wrote in message
news:du******** ************@co mcast.com...
>I know how to do this stuff so easily in VB6.........
>
> 3 questions.
>
> I have loaded a grid by binding it to a dataset. All is well with
> that.
>
> 1) How do I retrieve the value of a column when a user clicks on a
row? I
> use a Sheriden grid in VB6 and would do something like:
>
> MyString = MyGrid.Columns( n).Text
>
> 2) Some of the columns I'm pulling are datetime columns that have not

been
> set yet. I am getting (null) in the column. How do I prevent that

and > just
> display nothing?
>
> 3) I have a column that is a bit field. Before I applied any

formatting,
> the column came back as a greyed checkbox. The value at the time was
> (null). Now, with formatting and values, I'm getting True or False. I > want
> a checked or unchecked checkbox. How do I do that?
>
> Thanks in advance.
>
>
>



Nov 20 '05 #5

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

Similar topics

3
3355
by: Dmitry Akselrod | last post by:
Hi, I am using a standard .NET 1.0 Datagrid. Actually, I am using two, bound to a master-detail relationship. Both DataGrids are bound to a datasource. I have the MSDN version of the DateTime picker functioning quite well in the datagrid. I am also tracking a double-click event within another column in the datagrid. The column is just text. When the double-click event trigger fires, I load a borderless form, from which a user...
0
1140
by: Phil Townsend | last post by:
I am building an online testing application that uses a usercontrol to navigate through a list of questions. The questions are multiple choice. I have a stored procedure that returns two tables: questions & answers. I have defined a relationship in code using a DataRelation. I would like to use a datagrid to display the questions and answers in order to take advantage of paging offered with the datagrid. Where I am having difficulty is...
7
4670
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is quite ugly. The black area is larger then it is once an item is added. How can I solve this problem either by: A) Having only the header black and the rest of the empty block white or gray (preffered solution) B) Having the color gray or white...
5
1470
by: VB Programmer | last post by:
I have an ASP.NET form that allows people to answer survey questions. There could be from 5 to an unlimited amt of questions, depending on which questions the admin wants to users to answer (he sets it up previously). The questions are in a db. Is a datagrid the best way to display this data? What do you suggest? After they enter the info I want to be able to save it back to the db. Any helpful links/examples?
10
4941
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 the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
2
1437
by: Maarten | last post by:
Hi all, I have a datagrid with questions where the user has to make a choice (yes or no questions) But for some questions there are rules, like if you choose (yes or no) for some questions I need to skip 1 or more questions. e.g. Q1. Do you..... Y | N Q2. Do you..... Y | N
9
2117
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. For a datagrid control, i used the Caption property. It displays fine on the datagrid and allows me to run the program. But, when i view the HTML for the web form, it shows this error at the
9
2714
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
1
2152
by: RN1 | last post by:
Consider the following DataGrid: -------------------------------------------------------------------------------- <asp:DataGrid ID="dgMarks" AutoGenerateColumns="false" runat="server"> <Columns> <asp:TemplateColumn> <HeaderTemplate> <asp:CheckBox ID="chkHeader" OnCheckedChanged="CheckUncheckAllRows" AutoPostBack="true" runat="server"/> </HeaderTemplate>
2
6582
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
0
8319
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,...
0
8837
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, 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...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
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 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...
0
4171
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...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
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 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.