" Umut, hiç görmeyen birine gökkuşağını anlatmak kadar zor ve imkansız... "

Categories

-

C# DataGridView Dikey Satirlama,Hizalama !!!

Bu makalede, bir DataGrid kontrolunu Dikey Satirlayip gösterecegiz... Burada normal modda (Yatay Satir) ve (Dikey Satir) bir DataTable nesnesi ile bazi bilgileri içeren bir DataGridView ile bir C # uygulamasi tasarlayacagiz...

Yeni bir C.NET 2010 Windows uygulamasi olusturun.

OleDbConnection baglanti = new OleDbConnectio(@"Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + Directory.GetCurrentDirectory() + @"\iller.mdb");

OleDbDataAdapter adap = null;

OleDbDataReader dr = null;

DataSet ds = null;

DataTable dt = null;


Bazi veriler ile dolu bir DataTable nesnesi olusturuyoruz :


public DataTable GetCustomers()

{

DataTable table = new DataTable();

OleDbDataAdapter adap = new OleDbDataAdapter("Select * From sehir", baglanti);

adap.Fill(table);

//table.TableName = "sehir";

//table.Columns.Add("Name", typeof(string));

//table.Columns.Add("Price", typeof(string));

//table.Columns.Add("Country", typeof(string));

//table.Rows.Add(new object[] { "Mohamad", "1700", "Egypt" });

//table.Rows.Add(new object[] { "Tarek", "550", "Syria" });

//table.Rows.Add(new object[] { "Gamal", "762", "Saudi Arabia" });

//table.AcceptChanges();

return table;

}



OnLoad olayina asagidaki metotlari ekleyin :



private void dikey_hizalama()

{

ds = new DataSet();

dt = new DataTable();

dt = GetCustomers();

ds.Tables.Add(dt);

DataSet new_ds = FlipDataSet(ds); // Flip the DataSet

DataView my_DataView = new_ds.Tables[0].DefaultView;

this.dataGridView1.DataSource = my_DataView;

}



private void yatay_hizalama()

{

baglanti.Open();

adap = new OleDbDataAdapter("Select * from sehir", baglanti);

dt = new DataTable();

adap.Fill(dt);

dataGridView2.DataSource = dt;

baglanti.Close();

}



private void Form1_Load(object sender, EventArgs e)

{

this.dataGridView1.ColumnHeadersVisible = false;

dikey_hizalama();

yatay_hizalama();

}


FlipDataSet yöntemi olusturuyoruz :


public DataSet FlipDataSet(DataSet my_DataSet)

{

DataSet ds = new DataSet();

foreach (DataTable dt in my_DataSet.Tables)

{

DataTable table = new DataTable();

for (int i = 0; i <= dt.Rows.Count; i++)

{

table.Columns.Add(Convert.ToString(i));

}

DataRow r;

for (int k = 0; k < dt.Columns.Count; k++)

{

r = table.NewRow();

r[0] = dt.Columns[k].ToString();

for (int j = 1; j <= dt.Rows.Count; j++)

r[j] = dt.Rows[j - 1][k];

table.Rows.Add(r);

}

ds.Tables.Add(table);

}

return ds;

}

Örnek çalismayi buradan indirebilirsiniz...

  • 0
  • 3157
  • 1

- BUNLARIDA GÖZDEN GEÇİREBİLİRSİNİZ -

1 YORUM

  • Peggy

    Imagine having the best celebrity in the world to promote your websiteproduct …Like Elon Musk promoting your Tech softwareDonald Trump promoting your supplement productOr even Beyonce promoting your beauty product.Just name it, no matter the business you do online you can use my latest software Revio, to pull huge amounts of trafficsales into your pocket using Hollywood standard HD videos. Create Celebrity videos with Revio: https:www.bizopphand.inforevio Here is how it works…Revio is the only AI Studio Platform That Allows You To Upload Any “Static Picture Or 5Secs Clip” And Transform It Into Talking, or Singing Video.…With HyperRealistic Emotions, LipSync LifeLike Movement In Any Niche Language You WantIn just 60 seconds you can get any video you want ready either for your Instagram, TikTok or YouTube account that generates thousands of followers.Or you want a video for your website that pulls in limitless buyer traffic and pr0fit: https:www.bizopphand.inforevio Revio is the allinone solution for any salespulling video you will ever need.No Monthly ChargesNo Complicated temsNo writing and video editing ss are needed.All you have to do is follow the 3 simple steps;Step 1: Login to RevioStep 2: Upload any photo or celebrity you want to turn to talking or animation videosStep 3: Download the video in the next 2mins.That’s all you do and you are good to go, start dominating social media and your industry without stress.But, the catch is,Revio Earlybird access is limited, so you need to act fast before the price triples or we can decide to place it on a subion for subsequent lateentry users Create Celebrity and salepulling videos with Revio: https:www.bizopphand.inforevio Peggy StewartUNSUBSCRIBE: https:www.bizopphand.infounsubscribe?d=okanduzgun.com Address: 4829 Carson StreetLexington, KY 40505

    14.01.2025

Yorum yazın

HAKKIMDA

KONULARI TAKİP EDİN

SOSYAL AĞLAR

  • Mesajınızı Gonderin