" 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
  • 3255
  • 1

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

1 YORUM

  • Jackie

    How would you love to have expert AI Humans to Run Coaching Programs or Do Anything You Can Imagine,While you just accumulate profit at the backend.That’s why we built Human AI, especially for you.To transform your business without having to do the heavy work yourself.Human AI is the World’s First AI App That Lets You… Create Stream “AI Humans” That Listen, Think, ReactYou Can Clone Your Brain And Turn It Into “AI Human” with just a click. Let AI Humans do the work for you: https:www.unlockrevenue.infohumanai No Tech experience neededNo sales ss neededNo complicated setupIn fact, you never have to pay monthly to use the Human AIs…All you need is a onetime activation and you get access to;Create Stream AI Humans With Just 1 Click…Create an AI Human With “Clone” Of Your Brain, Knowledge, Tone, And Everything…AI Human Handles Any Task, Coaching Programs, Meetings, Interviews, From Sales to Live Streams, Customer Support, and more with zero effort.Feed Your AI Human With Knowledge From Any Pdfs, Doc, URL, Website, Books, Or Anything…Embed AI Humans Anywhere With a Single Line of Code (Websites, blogs, stores, funnels, or any platform AI Humans integrate seamlesslyTurn AI Humans Into a 247 Profit Machine…Start A Profi Business From Scratch With Human AI In Less Than 60 Seconds…You can see how effective Human AI can be for you and your online business…So whether you are into digital products, physical products or coaching programs, Human AI will change the game for you.You become the top player in any niche without sleepless nights… Grab Human AI here: https:www.unlockrevenue.infohumanai Jackie RappUNSUBSCRIBE: https:www.unlockrevenue.infounsubscribe?d=okanduzgun.com Address: 3141 Jim Rosa LaneOakland, CA 94612

    09.02.2025

Yorum yazın

HAKKIMDA

KONULARI TAKİP EDİN

SOSYAL AĞLAR

  • Mesajınızı Gonderin