Jump to content

Sistem Datatable


korasoglu
 Share

Recommended Posts

Arkadaşlar şimdiden her birinize çok teşekkür ederim, ben a uygulasındaki tabloyu  b uygulasında nasıl kullanabilirim. Yani a.exe de korasoglu  tablesine load yaptıktan sonra b.exeyi çağırdığım zaman form yüklenince korasoglu tablesini nasıl kullanabilirim. Mantık aynen şu excelde kopyalama yaptın başka kitap açtığın zaman yapıştırabiliyorsun demekki sistem hafızasında tablo kullanılabiliyor bu özelliği biz nasıl kullanabiliriz Araştırdım fakat dökümanlar ingilizce bir şey anlamadım bilen varsa yardımcı olursa çok sevinirim.

Link to comment
Share on other sites

hafızaya alıyoruz

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

var newline = System.Environment.NewLine;
            var tab = "\t";
            var hafiza = new StringBuilder();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    if (i == (row.Cells.Count - 1))
                        hafiza.Append(row.Cells.Value + newline);
                    else
                        hafiza.Append(row.Cells.Value + tab);
                }

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

hafızadan okuyoruz

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

DataTable tumu = new DataTable();
            int aa = -1;
            string[] aylar = {"2016","Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık" };
            DataObject o = (DataObject)Clipboard.GetDataObject();
            if (o.GetDataPresent(DataFormats.Text))
            {
                if (dg.RowCount > 0) dg.Rows.Clear();
                if (dg.ColumnCount > 0) dg.Columns.Clear();
                bool columnsAdded = false;
                string[] pastedRows = Regex.Split(o.GetData(DataFormats.Text).ToString().TrimEnd("\r\n".ToCharArray()), "\r\n");
                foreach (string pastedRow in pastedRows)
                {
                   
                    string[] pastedRowCells = pastedRow.Split(new char[] { '\t' });
                    if (!columnsAdded)
                    {
                        aa++;
                        for (int i = 0; i < pastedRowCells.Length; i++)
                        {
                            dg.Columns.Add(i.ToString(), aylar);
                            //dg.Columns.Add("col" + i, pastedRowCells);
                            tumu.Columns.Add(i.ToString());
                            aa++;
                            columnsAdded = true;
                            continue;
                        }

                            
                    }

                    dg.Rows.Add();
                    int myRowIndex = dg.Rows.Count - 1;
                   // MessageBox.Show(dg.Columns.Count.ToString());
                    using (DataGridViewRow myDataGridViewRow = dg.Rows[myRowIndex])
                    {
                        for (int i = 0; i < pastedRowCells.Length; i++)
                        {
                            myDataGridViewRow.Cells.Value = pastedRowCells;
                            
                            
                        }
                           
                        
                    }
                }
            }

ben zaten tablede columnsları oluşturuyorum sadace satırları ekleyemedim yani gelen veriyi tabloyada yüklemek istiyorum.

Edited by korasoglu
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...