PDA

View Full Version : سوال: تبديل كد سي شارپ



MOR_MS
پنج شنبه 28 دی 1391, 23:14 عصر
DataTable GetDataTable(GridView dtg)
{
DataTable dt = new DataTable();
// add the columns to the datatable
if (dtg.HeaderRow != null)
{
for (int i = 0; i < dtg.HeaderRow.Cells.Count; i++)
{
dt.Columns.Add(dtg.HeaderRow.Cells[i].Text);
}
}
// add each of the data rows to the table
foreach (GridViewRow row in dtg.Rows)
{
DataRow dr;
dr = dt.NewRow();
for (int i = 0; i < row.Cells.Count; i++)
{
dr[i] = row.Cells[i].Text.Replace(" ", "");
}
dt.Rows.Add(dr);
}
return dt;
}


باسلام
دوستان يه لطف كنن اين تابه را به زبان وي بي براي پروژه ويندوزي تبديل كنن ممنون ميشم

xxnagin
پنج شنبه 28 دی 1391, 23:18 عصر
سلام

Private Function GetDataTable(ByVal dtg As GridView) As DataTable
Dim dt As New DataTable()
' add the columns to the datatable
If dtg.HeaderRow IsNot Nothing Then
For i As Integer = 0 To dtg.HeaderRow.Cells.Count - 1
dt.Columns.Add(dtg.HeaderRow.Cells(i).Text)
Next i
End If
' add each of the data rows to the table
For Each row As GridViewRow In dtg.Rows
Dim dr As DataRow
dr = dt.NewRow()
For i As Integer = 0 To row.Cells.Count - 1
dr(i) = row.Cells(i).Text.Replace(" ", "")
Next i
dt.Rows.Add(dr)
Next row
Return dt
End Function

MOR_MS
پنج شنبه 28 دی 1391, 23:41 عصر
سلام
دوست عزيز معادل GridView در پروژه هاي ويندوزي فكر كنم DataGridView باشه كه وقي عوضش ميكنم گزينه هاي ديگر را ارور ميده

MOR_MS
پنج شنبه 28 دی 1391, 23:55 عصر
يه توضيح در مورد اين (تابه ) :خجالت:تابع اينكه اين تابع بايد با استفاده از اطلاعاتي كه در يك ديتا گريد ويو پر شده بياد يك جود با اسمهاي ستونهاي گريد درست كنه و اطلاعات را داخل ان بريزه و بعد اين جدول را به گزارش پاس بدم (
stimul report) پست 1127

لينك
http://barnamenevis.org/showthread.php?117526-%D8%B3%D9%88%D8%A7%D9%84%D8%A7%D8%AA-%D9%85%D8%B1%D8%A8%D9%88%D8%B7-%D8%A8%D9%87-StimulReport-%D8%B1%D9%88-%D8%AF%D8%B1-%D8%A7%DB%8C%D9%86-%D8%AA%D8%A7%D9%BE%DB%8C%DA%A9-%D9%85%D8%B7%D8%B1%D8%AD-%DA%A9%D9%86%DB%8C%D8%AF/page4&highlight=Stimulsoft+Reports+Ultimate

MOR_MS
جمعه 29 دی 1391, 01:24 صبح
سلام
موفق شدم درست كنم و گزارش از اين طريق با استفاده از Entity Framework بدست بيارم
نمي دونم چقدر كارم درسته من با استفاده از linq اطلاعات رو هرجوري كه ميخوام وارد يك ديتا گريد براي پيش نمايش كردم و بعد اين اطلاعات رو وارد يك جدول و از انجا به گزارش فرستادم دوستان اگه ممكنه بازم در اينمودر براي بهتر شدن راهنمايي كنن

پر كردن ديتا گريد

Dim id_darkhasti As Double = Me.DG_darkhasti.CurrentRow.Cells("darkhasti_id").Value()
Dim q_list = From i In ENT_SEPORDEH.View_Item_darkhasti_ENTSet Where i.darkhasti_item_darkasti_id = id_darkhasti Select i
Me.DataGridView1.DataSource = q_list.ToList



پاس دادن به تابع

GetDataTable(dtg:=Me.DataGridView1)

عمليات كار تابع و ايجاد گزارش
Private Function GetDataTable(dtg As DataGridView) As DataTable
Dim rpt As StiReport = New StiReport()
Dim dt As New DataTable()
' add the columns to the datatable
If dtg.CurrentRow IsNot Nothing Then
For i As Integer = 0 To dtg.CurrentRow.Cells.Count - 1
dt.Columns.Add(dtg.Columns.Item(i).HeaderText)
Next
End If

' add each of the data rows to the table
For Each row As DataGridViewRow In dtg.Rows
Dim dr As DataRow
dr = dt.NewRow()
For i As Integer = 0 To row.Cells.Count - 1
dr(i) = row.Cells(i).Value '.Replace(" ")
Next
dt.Rows.Add(dr)
Next
rpt.RegData(dt)
rpt.Load("form_darkhast.mrt")
rpt.Render()
My.Forms.Form_min_gozaresh.StiViewerControl1.Repor t = rpt
My.Forms.Form_min_gozaresh.StiViewerControl1.Show( )
My.Forms.Form_min_gozaresh.ShowDialog()
Return dt
End Function

علی جباری
سه شنبه 21 خرداد 1392, 19:51 عصر
سلام
آدرس زير جهت تبديل كد برنامه از يك زبان به زبان ديگر است:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

maxvel
سه شنبه 21 خرداد 1392, 19:58 عصر
اینم یکی دیگه

http://converter.telerik.com/