I think I am using the proper terminology here ... I am using VB 2003 and
have a DataGrid to which I then attach a TableStyle ... then I set the
properties of the TableStyle (BackColor, HeaderBackColor, etc.) ... then I
create several DataGridTextBoxColumns and set their properties (MappingName,
Width, Alignment, etc.) ... then I add these columns to the DataGridStyle.
Next, using the MappingNames I add the columns to a DataTable ... then I add
the DataTable to a DataSet ... and finally bind the DataSet to the DataGrid
so the user can see it (whew!). All of this seems incredibly complicated
when all I want to do is display some stuff in tabular form with some column
headers.
In any event, I would like to set the foreground color of a displayed row
based on the value of a particular item in the row ... yet with all these
constructs (table styles, textbox columns, data tables, etc.) I cannot
figure out how to do it. Can someone help me understand how to do this ...
or point me to an article that will help?
Thanks very much. 3 2647
fripper wrote: I think I am using the proper terminology here ... I am using VB 2003 and have a DataGrid to which I then attach a TableStyle ... then I set the properties of the TableStyle (BackColor, HeaderBackColor, etc.) ... then I create several DataGridTextBoxColumns and set their properties (MappingName, Width, Alignment, etc.) ... then I add these columns to the DataGridStyle. Next, using the MappingNames I add the columns to a DataTable ... then I add the DataTable to a DataSet ... and finally bind the DataSet to the DataGrid so the user can see it (whew!). All of this seems incredibly complicated when all I want to do is display some stuff in tabular form with some column headers.
In any event, I would like to set the foreground color of a displayed row based on the value of a particular item in the row ... yet with all these constructs (table styles, textbox columns, data tables, etc.) I cannot figure out how to do it. Can someone help me understand how to do this ... or point me to an article that will help?
Thanks very much.
Yes, your terminology is correct. I will say you could simplify it by
binding the datatable directly to the datagrid (make sure the tablename
equals the tablestyle.mappingname.) But now to your next question.
Unfortunately to do this you have to create your own
DataGridTextBoxColumns and override the onpaint method. It's not as
hard as you might think if you've never done it before. This article
walks you through it (it's in C# but the function calls are all there) http://www.codeproject.com/csharp/Cu...ColumnStyl.asp
The important function is:
protected override sub Paint(....)
public sub
dim bdel as boolean= ctype(GetColumnValueAtRow(Source, RowNum), bool)
if bdel then
BackBrush = Brushes.Coral
else
BackBrush = Brushes.White
end if
g.FillRectangle(BackBrush, Bounds.X, Bounds.Y, Bounds.Width,
Bounds.Height)
System.Drawing.Font font = new
Font(System.Drawing.FontFamily.GenericSansSerif,
(float)8.25 )
g.DrawString( bdel.ToString(), font, Brushes.Black, Bounds.X, Bounds.Y)
end sub
Thanks Chris ... that is very helpful. I have modified the program to bind
the datatable directly to the datagrid ... at least that eliminates one
unnecessary construct in the process.
Now I will see about adding my own onPaint method. It's a slow process but
I am gradually becoming more familiar with VB .Net. I have just installed
VB 2005 but have not yet ported this program over to it.
Thanks again.
"Chris" <no@spam.com> wrote in message
news:uk**************@tk2msftngp13.phx.gbl... fripper wrote: I think I am using the proper terminology here ... I am using VB 2003 and have a DataGrid to which I then attach a TableStyle ... then I set the properties of the TableStyle (BackColor, HeaderBackColor, etc.) ... then I create several DataGridTextBoxColumns and set their properties (MappingName, Width, Alignment, etc.) ... then I add these columns to the DataGridStyle. Next, using the MappingNames I add the columns to a DataTable ... then I add the DataTable to a DataSet ... and finally bind the DataSet to the DataGrid so the user can see it (whew!). All of this seems incredibly complicated when all I want to do is display some stuff in tabular form with some column headers.
In any event, I would like to set the foreground color of a displayed row based on the value of a particular item in the row ... yet with all these constructs (table styles, textbox columns, data tables, etc.) I cannot figure out how to do it. Can someone help me understand how to do this ... or point me to an article that will help?
Thanks very much.
Yes, your terminology is correct. I will say you could simplify it by binding the datatable directly to the datagrid (make sure the tablename equals the tablestyle.mappingname.) But now to your next question.
Unfortunately to do this you have to create your own DataGridTextBoxColumns and override the onpaint method. It's not as hard as you might think if you've never done it before. This article walks you through it (it's in C# but the function calls are all there)
http://www.codeproject.com/csharp/Cu...ColumnStyl.asp
The important function is:
protected override sub Paint(....)
public sub dim bdel as boolean= ctype(GetColumnValueAtRow(Source, RowNum), bool)
if bdel then BackBrush = Brushes.Coral else BackBrush = Brushes.White end if
g.FillRectangle(BackBrush, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height)
System.Drawing.Font font = new Font(System.Drawing.FontFamily.GenericSansSerif, (float)8.25 ) g.DrawString( bdel.ToString(), font, Brushes.Black, Bounds.X, Bounds.Y)
end sub
fripper wrote: Thanks Chris ... that is very helpful. I have modified the program to bind the datatable directly to the datagrid ... at least that eliminates one unnecessary construct in the process.
Now I will see about adding my own onPaint method. It's a slow process but I am gradually becoming more familiar with VB .Net. I have just installed VB 2005 but have not yet ported this program over to it.
Thanks again.
"Chris" <no@spam.com> wrote in message news:uk**************@tk2msftngp13.phx.gbl...
fripper wrote:
I think I am using the proper terminology here ... I am using VB 2003 and have a DataGrid to which I then attach a TableStyle ... then I set the properties of the TableStyle (BackColor, HeaderBackColor, etc.) ... then I create several DataGridTextBoxColumns and set their properties (MappingName, Width, Alignment, etc.) ... then I add these columns to the DataGridStyle. Next, using the MappingNames I add the columns to a DataTable ... then I add the DataTable to a DataSet ... and finally bind the DataSet to the DataGrid so the user can see it (whew!). All of this seems incredibly complicated when all I want to do is display some stuff in tabular form with some column headers.
In any event, I would like to set the foreground color of a displayed row based on the value of a particular item in the row ... yet with all these constructs (table styles, textbox columns, data tables, etc.) I cannot figure out how to do it. Can someone help me understand how to do this ... or point me to an article that will help?
Thanks very much.
Yes, your terminology is correct. I will say you could simplify it by binding the datatable directly to the datagrid (make sure the tablename equals the tablestyle.mappingname.) But now to your next question.
Unfortunately to do this you have to create your own DataGridTextBoxColumns and override the onpaint method. It's not as hard as you might think if you've never done it before. This article walks you through it (it's in C# but the function calls are all there)
http://www.codeproject.com/csharp/Cu...ColumnStyl.asp
The important function is:
protected override sub Paint(....)
public sub dim bdel as boolean= ctype(GetColumnValueAtRow(Source, RowNum), bool)
if bdel then BackBrush = Brushes.Coral else BackBrush = Brushes.White end if
g.FillRectangle(BackBrush, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height)
System.Drawing.Font font = new Font(System.Drawing.FontFamily.GenericSansSeri f, (float)8.25 ) g.DrawString( bdel.ToString(), font, Brushes.Black, Bounds.X, Bounds.Y)
end sub
In 2005 you can use the DataGridView which makes everything much much
easier. If you're considering the upgrade you may want to do it sooner
and switch over the control.
Note: The DataGridView is for viewing one table only, unlike the
DataGrid which can show off relationships.
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: TF |
last post by:
hi,
i am using a ListBox control on a windows form using VB.Net. when i
set the DataSource property of the control to an ArrayList it fires
following events in this order:
SelectedIndexChanged...
|
by: Mervin Williams |
last post by:
I am trying to set the text property of one of my labels in a data grid to
the value of a text box in the same datagrid.
Please help!
Mervin Williams
|
by: Dennis |
last post by:
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridrows" method. However, this does
not work for classes that inherit from...
|
by: cr113 |
last post by:
I'm trying to set the column widths for a datagrid. You'd think it
would be easy. I looked it up in google and the first thing I found
looked promising:
datagrid1.columns(0).width = 2000...
|
by: fripper |
last post by:
After a good bit of urging from folks in this newsgroup I have begun to
become familiar with the VB .Net DataGrid control as a replacement for one
my favorite VB6 controls ... the FlexGrid. In any...
|
by: Rich |
last post by:
Hello,
I have a one datagrid that will be based on different datatables. One
datatable may have 7 columns, another 15... With the tables that have more
columns, I have been manually dragging...
|
by: MLH |
last post by:
Setting form's Picture property to another file from within
VBA doesn't repaint the form with new bitmap - for instance...
Me.Picture = "c:\pics\MyNewPic.jpg"
I tried
Me.Repaint
afterward,...
|
by: Blackbrand |
last post by:
I'll start off with what i'm trying to do:
i want to search my data programmatically and then jump to the row in the datagrid.
My data will almost allways go out of the datagrids bounds so if the...
|
by: Iain Wilson |
last post by:
Hi All
I would like to set the width of the bottom line of a datagrid row at
runtime.
I know how to set the complete lines style color etc at runtime but I
cannot figure how to change the...
|
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:
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
| |