|
|
Yes, everything declared, thanks for the info, this is eactly what I was looking for. I ama happy customre!
|
|
|
|
|
I am trying to build GrirdViews and ObjectDatsources dynamically as it could be any number.
I have built the grid no problems but i cannot work how to build the objectdataource dynamically.
Grid = New ReportingGrid
DataSource = New ObjectDataSource
DataSource.ID = "ODS" & Counter
DataSource.SelectMethod = "ReturnDataTable"
DataSource.TypeName = "Eurofins.EOLDotNET.SummaryReport"
DataSource.Select()
Grid.DataSource = DataSource.ID.ToString
Grid.DataBind()
This however creates a new version of the SummaryReport class so there is no data to retrieve.
Basically I have the data in a dataset that is global to the class and I wan to create a ObjectDataSource and assign it to this dataset.
Any ideas would be very welcome.
Sorry bout this post but I'm quite new to these sort of things.
|
|
|
|
|
In VB2005, I've done an application and a library that is used within the application. Both of them call a function that is placed in the library and that permits to write a message in the same logfile.
I'd like to add the caller's name in the log file so each message in the log would have the source that has written the line. For example:
appname.exe: error msg ...
libname.dll: error msg ...
Is there any way to retrieve the caller's name from within the function?
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Try Application.ProductName
|
|
|
|
|
No, it always returns the same name
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Try System.Reflection.Assembly.GetCallingAssembly.
|
|
|
|
|
Great, perfect.
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
I have an MDI application. I want to place a form in this application with the restriction that it is not an MDI chaild. But I want that its is owned by the MDI form. IF the application is on behind another application, then this form automatically goes back with its Owner and is brought into focus again whenever its owner is clckied.....
Adeem Zashir
|
|
|
|
|
I am creating a program which I am starting error correcting to minimize errors (as you do). I would like to know, is it possible to make a error appear this way:
ErrorForm (Form with text box that displays error). I want, if you can do this, put the gorm within a small balloon or make the balloon look similar to Windows Vista glass background instead.
on the top of the balloon I would like a ? button and when you press this it will bring up file ErrorReports.htm which is located in same folder as program. Any suggestions?
I'd prefer the glass vista balloon look apposed to the normal look. Need code for ? on button fast.
Like balloon (part where text is displayed) to be look sort of like this (minus windows logo and be not much bigger than normal balloon):
http://files.myopera.com/toanlh/albums/90145/3.jpg[^]
I'm using VB 2005.
In the end we're all just the same
|
|
|
|
|
I have use datagridview in my application, 4 columns, 10 rows, I want to sum record in first row, how can i do? please give me example?
Thanks
................
|
|
|
|
|
cryat a datagrid coulm Price , Quantity
something lik Price * Quantity
[Price] [Quantity]
10 100
Private Sub DataGrid1_CurrentCellChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
Dim a As Integer = DataGrid1.CurrentRowIndex.ToString
dim Price as Integer =DataGrid1.Item(a, 0)
dim Quantity as Integer = DataGrid1.Item(a, 1)
dim totale as Integer = Price * Quantity
msgbox(totale)
End Sub
:->
Ahmed El-Badry
|
|
|
|
|
i want to replase pic from pictuerbox but its not worked
thats my code
dim Aids as Integer = DataSet11.Admin.Item(0).AID.Trim
Dim fileinfo As String = OpenFileDialog1.FileName.Trim '//new Pic file
Dim fileex As String = Path.GetExtension(fileinfo.Trim)
Dim newdrfile As String = "C:\GymProg\Adminpic\" + AIDS.ToString.Trim + fileex.Trim '// new dirctry file
Dim oldpic As New FileInfo(DataSet11.Admin.Item(0).Pic.Trim) '// old pic thes is Problem Because oldpic.Path = newderfile.Path
'//Delete old Pic
If File.Exists(oldpic.FullName) = True Then
oldpic.Delete() ''//The process cannot access the file "C:\GymProg\Adminpic\1.gif" because it is being used by another process.
another Process like pictuerbox1.image path
End If
'//creat new Pic
FileCopy(fileinfo.Trim, newdrfile.Trim)
Ahmed El-Badry
|
|
|
|
|
hallo friends,
i wnt one column in my datagridview as a combobox & wnt to fill combobox by fetching values frm the database.
my question is how to add comboBox as a column in DatagridView through coding & how to fill it by fetching values frm database?
it is urgent please help me.
priya
|
|
|
|
|
First you have to fill the dataset as done in the below getdataset(). Then in the rowdatabound event of the Gridview bind Dropdownlist with the dataset. In the page_load event you only need to bind the GridView.
'Function to fill the dataset
Private Function getdataset() As DataSet
Dim connectionstring As String = "Data Source=localhost;Initial Catalog=northwind;User ID=sa;password="
Dim query As String = "select p.categoryid,p.productid, p.productname,c.categoryid,c.categoryname from products p,categories c where p.categoryid=c.categoryid and c.categoryid<3"
Dim myconnection As New SqlConnection(connectionstring)
Dim ad As New SqlDataAdapter(query, myconnection)
Dim ds As New DataSet()
ad.Fill(ds)
Return ds
End Function 'getdataset
******************************************************************************
'Code in rowdatabound event to bind DropDownList to GridView
Protected Sub gridview1_rowdatabound(sender As Object, e As GridViewRowEventArgs)
Dim mytable As New DataTable()
Dim productidcolumn As New DataColumn("productid")
Dim productnamecolumn As New DataColumn("productname")
mytable.Columns.Add(productidcolumn)
mytable.Columns.Add(productnamecolumn)
Dim ds As New DataSet()
ds = getdataset()
Dim categoryid As Integer = 0
Dim expression As String = String.Empty
If e.Row.RowType = DataControlRowType.DataRow Then
categoryid = Int32.Parse(e.Row.Cells(0).Text)
expression = "categoryid = " + categoryid
Dim ddl As DropDownList = CType(e.Row.FindControl("dropdownlist1"), DropDownList)
Dim rows As DataRow() = ds.Tables(0).Select(expression)
Dim row As DataRow
For Each row In rows
Dim newrow As DataRow = mytable.NewRow()
newrow("productid") = row("productid")
newrow("productname") = row("productname")
mytable.Rows.Add(newrow)
Next row
ddl.DataSource = mytable
ddl.DataTextField = "productname"
ddl.DataValueField = "productid"
ddl.DataBind()
End If
End Sub 'gridview1_rowdatabound
******************************************************************************
'Page Load event
Protected Sub Page_Load(sender As Object, e As EventArgs)
gridview1.DataSource = getdataset().Tables(0)
gridview1.DataBind()
End Sub 'Page_Load
******************************************************************************
{Souce}
GridviewNestingDropdowlist
<asp:gridview id="gridview1" runat="server" autogeneratecolumns="False" onrowdatabound="gridview1_rowdatabound">
<columns><asp:boundfield datafield="categoryid" headertext="categoryid">
<asp:boundfield datafield="categoryname" headertext="category name">
<asp:boundfield datafield="productid" headertext="productid">
<asp:templatefield headertext="products">
<itemtemplate>
<asp:dropdownlist id="dropdownlist1" runat="server">
|
|
|
|
|
Good Morning,
Thnank you so much for your help. but i didnt see page load event in my form....i think this coding is for asp.net ....& i m developing application in vb.net(Winforms)!
So please if you have such coding in vb.net application Please help me.
priya
|
|
|
|
|
hi....
u can do this it worked for me
call this creategrid func from formload()
Public Sub creategrid()
'Declare and initialize local variables used
Dim dtCol As DataColumn = Nothing 'Data Column variable
'Create the String array object, initialize the array with the column names to be displayed
'arrstr = New String(9) {"Start Date", "End Date", "Start Time", "End Time", "Price", "Least Count", "Valid Days", "Remarks", "Booked slots", "Delete"}
arrstr = New String(8) {"Start Date", "End Date", "Start Time", "End Time", "Price", "Least Count", "Valid Days", "Remarks", "Booked slots"}
'Create the Data Table object which will then be used to hold columns and rows
dataTable = New DataTable("Controls")
'Add the string array of columns to the DataColumn object
Dim icnt As Integer
Try
For icnt = 0 To arrstr.Length - 1
Dim str As String = arrstr(icnt)
dtCol = New DataColumn(str)
dtCol.DataType = System.Type.GetType("System.String")
dtCol.DefaultValue = ""
dataTable.Columns.Add(dtCol)
Next icnt
If sAction = "Add" Then
Dim blrow As DataRow
blrow = dataTable.NewRow
dataTable.Rows.Add(blrow)
End If
'Set the Data Grid Source as the Data Table created above
dgAddInv.DataSource = dataTable
Dim cm As CurrencyManager
cm = CType(Me.BindingContext(dgAddInv.DataSource, dgAddInv.DataMember), CurrencyManager)
CType(cm.List, DataView).AllowNew = False
'set style property when first time the grid loads, next time onwards it will maintain its property
If Not dgAddInv.TableStyles.Contains("Controls") Then
'Create a DataGridTableStyle object
'Set its properties
dgdtblStyle.MappingName = dataTable.TableName
dgdtblStyle.RowHeadersVisible = True
dgAddInv.TableStyles.Add(dgdtblStyle)
Dim colStyle As GridColumnStylesCollection
colStyle = dgAddInv.TableStyles(0).GridColumnStyles
colStyle(8).ReadOnly = True
colStyle(8).NullText = "--New--"
'colStyle(1).Width = 220
'dgdtblStyle.RowHeadersVisible = False
dgdtblStyle.PreferredRowHeight = 22
dgdtblStyle.PreferredColumnWidth = dgdtblStyle.PreferredColumnWidth + 10
dgAddInv.BackgroundColor = Color.White
End If
'Take the text box from the second column of the grid where u will be adding the controls of your choice
datagridtextBox = CType(dgAddInv.TableStyles(0).GridColumnStyles(0), DataGridTextBoxColumn)
datagridtextBox1 = CType(dgAddInv.TableStyles(0).GridColumnStyles(1), DataGridTextBoxColumn)
datagridtextBox2 = CType(dgAddInv.TableStyles(0).GridColumnStyles(2), DataGridTextBoxColumn)
datagridtextBox3 = CType(dgAddInv.TableStyles(0).GridColumnStyles(3), DataGridTextBoxColumn)
datagridtextBox4 = CType(dgAddInv.TableStyles(0).GridColumnStyles(6), DataGridTextBoxColumn)
'for least count and price
datagridtextBox5 = CType(dgAddInv.TableStyles(0).GridColumnStyles(4), DataGridTextBoxColumn)
datagridtextBox6 = CType(dgAddInv.TableStyles(0).GridColumnStyles(5), DataGridTextBoxColumn)
Catch oexp As Exception
ShowMsgBoxErrorOk(oexp)
End Try
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''and then addd ur controls in mouse down event as below
Private Sub DGAddInv_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgAddInv.MouseDown
hitTestGrid = dgAddInv.HitTest(e.X, e.Y)
If Not (hitTestGrid Is Nothing) Then
If hitTestGrid.Type = DataGrid.HitTestType.Cell Then
dtp = New DateTimePicker
dtp.Dock = DockStyle.Fill
dtp.Cursor = Cursors.Arrow
dtp.Format = DateTimePickerFormat.Custom
dtp.CustomFormat = "MM/dd/yyyy"
dtp.ShowUpDown = False
For i = 0 To dataTable.Columns.Count - 1
sType = dgAddInv(0, i).ToString()
If hitTestGrid.Column = i Then
Select Case hitTestGrid.Column
'Add and show the control of ur choice
Case 0
datagridtextBox.TextBox.Controls.Add(dtp)
If dgAddInv.Item(hitTestGrid.Row, 0) <> "" Then
dtp.Value = CType(dgAddInv.Item(hitTestGrid.Row, 0), Date).ToShortDateString
End If
dtp.BringToFront()
End Select
End If
datagridtextBox.TextBox.BackColor = Color.White
Next i
end if
end if
end sub
see if that works for u ...u will have to change a bit as per your control as i am adding a datetime picker u can add a combo instead....
-- modified at 2:33 Thursday 25th January, 2007
" There are 10 types of people one who understands binary and one who don't................."
|
|
|
|
|
I am sorry about posting ASP code.
You can not set a datatable or dataview as the datasource for a combobox inside a Grid. In the following code I have given an ArrayList as the datasource for it. You can easily store a column into an ArrayList that is also done here. Please note that you have to set the AutoGenerateColumns property of the Grid to 'false' and add col's manually. I hope you know how to do that. The columns from the table 'product' which is in the database are: 'pname' and 'price'. And the manually added colmn names of the Grid 'Dg_Test' are: 'pname', 'Price' and 'type'. The third column in Dg_Test is the one you want that is of type DataGridViewComboBoxColumn. Other two pname and Price are DataGridViewTextBoxColumn. The value for third col'n is taken from a different table 'producttype' with field 'type'. I have not added any code regarding database connectivity for OleDbConnection.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Fill_Grid()
End Sub
Private Sub Fill_Grid()
Dim stt As String = "Select * from product"
Dim Cmd As OleDbCommand
Dim Adaptor As OleDbDataAdapter
Dim Ds As New DataSet
Dim dt As DataTable
Dim arList As New ArrayList
'Add columns manually using smart tag of the GridView column names are pname,Price,type
Dg_Test.AutoGenerateColumns = False
dbObj.OpenConnection()
Cmd = dbObj.ReturnOledbCommand(stt)
Adaptor = New OleDbDataAdapter(Cmd)
Adaptor.Fill(Ds, "product")
dt = Ds.Tables("product")
Me.Dg_Test.DataSource = dt
'Type cast the column pname and Price to DataGridViewTextBoxColumn and set the DataPropertyName to the
'field names in the database
Dim Name As DataGridViewTextBoxColumn = CType(Dg_Test.Columns("pname"), DataGridViewTextBoxColumn)
Name.DataPropertyName = "pname" 'pname is the field from the table in database
Dim Price As DataGridViewTextBoxColumn = CType(Dg_Test.Columns("Price"), DataGridViewTextBoxColumn)
Price.DataPropertyName = "price" 'price is the field from the table in database
'Datasource for DataGridViewComboBoxColumn
stt = "Select type from producttype"
Cmd = dbObj.ReturnOledbCommand(stt)
Adaptor = New OleDbDataAdapter(Cmd)
Adaptor.Fill(Ds, "producttype")
dt = Ds.Tables("producttype")
'Insert elemants into array list from dt
For Each dr As DataRow In dt.Rows
arList.Add(dr(0)) 'dr contains only one column
Next
Dim Type As DataGridViewComboBoxColumn = CType(Dg_Test.Columns("type"), DataGridViewComboBoxColumn)
Type.DataSource = arList 'Datasource is set to an arraylist
dbObj.CloseConnection()
End Sub
|
|
|
|
|
I am inserting values in a datagridview bounded to a dataset. It working normally. If i click on an empty row on the datagriview and did not enter a value, when i try to insert in the database, it is inserting a null value in the database although it is not present in the dataset.
Database error
|
|
|
|
|
hey u can use the currency manager ..it keeps the grid enabled but stops adding new rows in the grid...probably the best option for u ....here is the code...to do that...
Dim cm As CurrencyManager
cm = CType(Me.BindingContext(dgAddInv.DataSource, dgAddInv.DataMember), CurrencyManager)
CType(cm.List, DataView).AllowNew = False
it worked for me .........
" There are 10 types of people one who understands binary and one who don't................."
|
|
|
|
|
Thx for ur help. I tried ur code, it did not work with me. It forbids me to add a now row in the datagridview at runtime. I need it to allow me add rows at runtime but if i clicked on a new row and did not enter values in it, i want it not to insert it in the database. Help!
It did not work.
|
|
|
|
|
hey well then we have a work around that u can try......once user adds a blank row and clicks on save with nulls in that row ....delete that row from datatable as follows...
lets say actual datatable name is dataTable
and the temp one we are creating for manipulating is temptable
temptable = dataTable
For dtblnkrowcnt = 0 To dataTable.Rows.Count - 1
For colcount = 0 To dataTable.Columns.Count - 2
'u can check for blank or system.dbnull.value as suitable.....
If dataTable.Rows(dtblnkrowcnt).Item(colcount) = "" Then
blankcount = blankcount + 1
End If
Next
If blankcount = dataTable.Columns.Count - 1 Then
temptable.Rows(dtblnkrowcnt).Delete()
End If
blankcount = 0
Next
temptable.AcceptChanges()
dataTable = temptable
i know its just a workaround but it should fix up the issue ....best of luck dude.....
" There are 10 types of people one who understands binary and one who don't................."
|
|
|
|
|
I am inserting values in a datagridview bounded to a dataset. It working normally. If i click on an empty row on the datagriview and did not enter a value, when i try to insert in the database, it is inserting a null value in the database although it is not present in the dataset.
|
|
|
|
|
DataGrid1.Enabled = False
that is worked
Ahmed El-Badry
|
|
|
|
|
Thx for ur help . But i tried it before and it did not work. I need to keep the datagridview enabled to add rows at run time but i do not want it to add null rows.
Thx but it did not work.
|
|
|
|