TYPE FIELDS IN DATAGRIDVIEW COLUMN
Hi guy...........
dt.column.add("DATE",getType(DATE))
dt.column.add("Number",getType(string))
dt.column.add("%Con",getType(system.Int32))
dt.column.add("%Fac",getType(system.Int32))
dt.column.add("Total",getType(string))
my question is.........
1.column %Con , i need Numeric field...HOW????????
2.atcually what means "system.Int32" ???????????
3.How to do %con + %fac=total.....................what type field must i select
somebody help me............
Answers
- DataGridView1(e.columnIndex,e.rowIndex).Value = "ALLOW"
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!- Marked As Answer bymipakteh Monday, November 09, 2009 10:15 AM
All Replies
- The code above adds the following column types:
Dim dt As New DataTable dt.Columns.Add("DATE", GetType(Date)) dt.Columns.Add("Number", GetType(String)) dt.Columns.Add("%Con", GetType(System.Int32)) dt.Columns.Add("%Fac", GetType(System.Int32)) dt.Columns.Add("Total", GetType(String))
Date, String, Integer, Integer, and String
System.Int32 is an integer (a number). So you already have what you need.
If you want total to be Con + Fac, then it should be System.Int32 as well instead of string.
Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS! - Here is a little bit of code:
Dim dt As New DataTable dt.Columns.Add("DATE", GetType(Date)) dt.Columns.Add("Number", GetType(String)) dt.Columns.Add("%Con", GetType(System.Int32)) dt.Columns.Add("%Fac", GetType(System.Int32)) dt.Columns.Add("Total", GetType(System.Int32)) Dim dr As DataRow dr = dt.Rows.Add(#10/15/2009#, "This is a string", _ 10, 15) dr("Total") = dr.Field(Of Integer)("%Con") + dr.Field(Of Integer)("%Fac")
Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS! - Very similar to DeborahK but uses an expression for the total column. The result of the one row in this example shows the total column equalling 20, as the column expression adds both con and fac together.
Dim ColumnExpression As String = "Con + Fac" Dim Table As New DataTable With Table.Columns .AddRange(New DataColumn() _ { _ New DataColumn("Date", GetType(Date)), _ New DataColumn("Number", GetType(System.Int32)), _ New DataColumn("Con", GetType(System.Int32)), _ New DataColumn("Fac", GetType(System.Int32)), _ New DataColumn("ColumnC", GetType(System.Int32), _ ColumnExpression) _ } _ ) End With Table.Rows.Add(New Object() {#1/1/2009#, 1, 10, 10}) For Each row As DataRow In Table.Rows Console.WriteLine("[{0}][{1}][{2}][{3}][{4}]", _ row.Item(0), _ row.Item(1), _ row.Item(2), _ row.Item(3), _ row.Item(4)) Next
KSG - THANK DEBORAHK.......SUCCESSED
I have one more question .....
dt.column.add("DATE",getType(DATE))
dt.column.add("Number",getType(string))
dt.column.add("%Con",getType(system.Int32))
dt.column.add("%Fac",getType(system.Int32))
dt.column.add("Total",getType(string))
dt.column.add("RANGE",getType(string))
i put this code in Cell_formating
-------------------------------------------
if Datagridview1.columns(e.columnindex)="%total" then
if e.value =2 then
column("RANGE")="ALLOW"---------------i dont know how to assign to the column "RANGE"
end if
end if
please help deborahk........or other coding - A few things:
1) If you expect that the "%" sign somehow defines the value to be an integer, that is NOT correct. You are storing strings "%Con", so the "%" sign is just another character in the string.
So if your column name is "Total", you cannot then reference it as "%total".
2) To put a value into a cell, you need to use the same syntax: DataGridView1(e.columnIndex,e.rowIndex).Value = "ALLOW"
Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS! - yes....deborahk, that true what you said.
dt.column.add("DATE",getType(DATE))
dt.column.add("Number",getType(string))
dt.column.add("%Con",getType(system.Int32))
dt.column.add("%Fac",getType(system.Int32))
dt.column.add("Total",getType(system.Int32))
dt.column.add("RANGE",getType(string))
i need column(RANGE)=ALLOW if the value in column(Total) =2
please give me the other coding or change to other event from cellformating
thank deborahk - DataGridView1(e.columnIndex,e.rowIndex).Value = "ALLOW"
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!- Marked As Answer bymipakteh Monday, November 09, 2009 10:15 AM
- thank deborakh............


