Qator["Xarajatlar"] =15; Qator["Daromat"] =45;
Qator["Sof daromat"] =Convert::ToInt64(Qator["Daromat"])-
Convert::ToInt64(Qator["Xarajatlar"]);
Jadval->Rows->Add(Qator);
//5- qatorni qo'shamiz:
Qator = Jadval->NewRow();
Qator["Oy"] ="Sentyabr"; Qator["Sotib olingan max.soni"]=50;
Qator["Xarajatlar"] =20; Qator["Daromat"] =55;
Qator["Sof daromat"] =Convert::ToInt64(Qator["Daromat"])-
Convert::ToInt64(Qator["Xarajatlar"]);
Jadval->Rows->Add(Qator);
dataGridView1->DataSource = Jadval;
chart1->DataSource = Jadval;
chart1->Series["Series1"]->XValueMember = "Oy";
chart1->Series["Series2"]->XValueMember = "Oy";
chart1->Series["Series1"]->YValueMembers = "Sotib olingan max.soni";
chart1->Series["Series2"]->YValueMembers = "Sof daromat";
chart1->Series["Series1"]->ChartType =
System::Windows::Forms::DataVisualization::Charting::
SeriesChartType::Column;
chart1->Series["Series2"]->ChartType =
System::Windows::Forms::DataVisualization::Charting::
SeriesChartType::Column;
// Diogrammaning turi quyidagicha bo'lishi ham
//mumkin. masalan: Pie, Line va bohqa.
chart1->Series["Series1"]->Color = Color::Aqua;
chart1->Series["Series2"]->Color = Color::Yellow;
chart1->DataBind();} }
Button1 tugmasini click xodisasining kodlari quyidagicha:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {dio(); }
void dio(){
this->Text = "Grafik ma'lumotlar";
Jadval = gcnew DataTable();
Jadval->Columns->Add("Oy", String::typeid);
Jadval->Columns->Add("Sotib olingan max.soni", Int64::typeid);
Jadval->Columns->Add("Xarajatlar", Int64::typeid);
Jadval->Columns->Add("Daromat", Int64::typeid);
Jadval->Columns->Add("Sof daromat", Int64::typeid);
DataRow ^ Qator = Jadval->NewRow();
Qator["Oy"] = dataGridView1->Rows[0]->Cells[0]->Value;
Qator["Sotib
olingan max.soni"] =dataGridView1->Rows[0]->Cells[1]->Value;
Qator["Xarajatlar"] =dataGridView1->Rows[0]->Cells[2]->Value;
Qator["Daromat"] =dataGridView1->Rows[0]->Cells[3]->Value;
Qator["Sof daromat"] =Convert::ToInt64(dataGridView1->
Rows[0]->Cells[3]->Value) -Convert::ToInt64(
dataGridView1->Rows[0]->Cells[2]->Value);
Jadval->Rows->Add(Qator);
Qator = Jadval->NewRow();
Qator["Oy"] =dataGridView1->Rows[1]->Cells[0]->Value;
Qator["Sotib olingan max.soni"] = dataGridView1->Rows[1]-
>Cells[1]->Value;
Qator["Xarajatlar"] =dataGridView1->Rows[1]->Cells[2]->Value;
Qator["Daromat"] =dataGridView1->Rows[1]->Cells[3]->Value;
Qator["Sof daromat"] =Convert::ToInt64(dataGridView1-> Rows[1]->Cells[3]->Value) -Convert::ToInt64(
dataGridView1->Rows[1]->Cells[2]->Value);
Jadval->Rows->Add(Qator); Qator = Jadval->NewRow();
Qator["Oy"] = dataGridView1->Rows[2]->Cells[0]->Value;
Qator["Sotib
olingan max.soni"] = dataGridView1->Rows[2]->Cells[1]->Value;
Qator["Xarajatlar"] =dataGridView1->Rows[2]->Cells[2]->Value;
Qator["Daromat"] =dataGridView1->Rows[2]->Cells[3]->Value;
Qator["Sof daromat"] =Convert::ToInt64( dataGridView1->Rows[2]->Cells[3]->Value) –
Convert::ToInt64(dataGridView1->Rows[2]->Cells[2]->Value);
Jadval->Rows->Add(Qator); Qator = Jadval->NewRow();
Qator["Oy"] = dataGridView1->Rows[3]->Cells[0]->Value; Qator["Sotib olingan max.soni"] = dataGridView1->Rows[3]-
>Cells[1]->Value;
Qator["Xarajatlar"] =dataGridView1->Rows[3]->Cells[2]->Value;
Qator["Daromat"] =dataGridView1->Rows[3]->Cells[3]->Value;
Qator["Sof daromat"] =Convert::ToInt64(dataGridView1->Rows[3]-
>Cells[3]->Value) -Convert::ToInt64(
dataGridView1->Rows[3]->Cells[2]->Value);
Jadval->Rows->Add(Qator); Qator = Jadval->NewRow();
Qator["Oy"] = dataGridView1->Rows[4]->Cells[0]->Value; Qator["Sotib olingan max.soni"] = dataGridView1->Rows[4]-
>Cells[1]->Value;
Qator["Xarajatlar"] =dataGridView1->Rows[4]->Cells[2]->Value;
Qator["Daromat"] =dataGridView1->Rows[4]->Cells[3]->Value;
Qator["Sof daromat"] =Convert::ToInt64(
dataGridView1->Rows[4]->Cells[3]->Value) -Convert::ToInt64( dataGridView1->Rows[4]->Cells[2]->Value);
Jadval->Rows->Add(Qator);
// chart1 komponentasiga Jadvalni eksport qilish
chart1->DataSource = Jadval;
//chart1 komponentasidagi Serie1 ning X kordinatasiga Oy so'zini yozish
chart1->Series["Series1"]->XValueMember = "Oy";
// chart1 komponentasidagi Serie1 ning X kordinatasiga Oy so'zini yozish
chart1->Series["Series2"]->XValueMember = "Oy//chart1 komponentasidagi
//Serie1 ning Y kordinatasiga Sotib olingan max.soni so'zini yozish
chart1->Series["Series1"]->YValueMembers = "Sotib olingan max.soni";
// chart1 komponentasidagi Serie2 ning Y kordinatasiga Sof daromat so'zini yozish
chart1->Series["Series2"]->YValueMembers = "Sof daromat";
chart1->Series["Series1"]->ChartType = System::Windows::Forms::
DataVisualization::Charting::SeriesChartType::Column;
chart1->Series["Series2"]->ChartType = System::Windows::Forms::
DataVisualization::Charting::SeriesChartType::Column;
chart1->Series["Series1"]->Color = Color::Aqua;
chart1->Series["Series2"]->Color = Color::Green;
//chart1->Series["Series1"]->IsVisibleInLegend = false;
chart1->DataBind();
//DadaGridView1 komponentasiga Jadvalni eksport qilish
dataGridView1->DataSource = Jadval; }
qadam. Jadvaldan kiritilgan qiymatlar natijaga darxol ta`sir qilishi uchun dataGridView1 ning CellEndEdit xodisasiga dio() funksiyasi chaqiriladi. Ahamiyat bеrilgan bo‘lsa, button1 ga ham chaqirilgan edi. Ushbu kod quyidagicha:
private: System::Void dataGridView1_CellEndEdit(System::Object^
sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
3. dio(); }
qadam. listBox1 da diagrammani ko‘rinishlarini o‘zgartirish mumkin. Buning uchun listBox ning SelectedIndexChanged hodisasining kodlari quyidagicha bo‘lishi kеrak:
private: System::Void listBox1_SelectedIndexChanged(System::Object^
sender, System::EventArgs^ e) {
if (listBox1->Text == "Transparent") return;
this->chart1->Series["Series1"]->ChartTypeName=(listBox1->Text) ;
this->chart1->Series["Series2"]->ChartTypeName=(listBox1->Text) ;
}
Dasturda diagrammani ko‘rinishi quyidagicha:
3.39- rasm. Diagrammani sozlash oynasi
Veb brouzеrda HTML jadvallarni tasvirlash va shakllantirish
Bizga ma`lumki HTML tеglari yordamida vеb ilovalar yaratiladi va bu ilovalar jamlanib, vеb sayt tashkil etiladi. Vеb ilovalarni yoki global tarmoqga ulangan saytlarni amaliy dasturda ochish imkonini bеruvchi komponеnta bu WebBrowser komponеntasi hisoblanadi. Ushbu komponеnta orqali nafaqat saytlarni ochish, balki HTML kodlarida tеrilgan tеkst (tеg) larni ham chiqarish va tahrirlash imkoniyatlari mavjud. Quyidagi namunada tuziladigan dasturda HTML tеglari ishlatilgan. Masalan: -matnni 16 shriftda ko‘rsatadi.
- jadval yaratadi. -jadvalning ustunini yaratadi. - jadvalning satrlarini yaratadi. 8- jadvalda kеltirilgan ma`lumotlar matnli faylda tashkil qilinadi. Ushbu fayl o‘qish uchun ochiladi va uning ma`lumotlari ma`lum o‘zgaruvchilarga o‘zlashtirilgan holda, sikl asnosida webBrowser komponеntasi yordamida ekranga tartiblangan ko‘rinishida chiqariladi.
Ushbu vazifani bajaruvchi dasturni tuzish uchun Visual Studio 2012 dasturi ishga tushiriladi, asosiy oyna mеnyu bo‘limlaridan File-
>New->Project… buyruqlari bеriladi yoki Ctrl+Shift+N klavishalari bosiladi, ochilgan oynada loyihaga “HTML_xujjatlar ” nomi bеrilib OK tugmasi bosiladi. Dasturning umumiy ko‘rinishi quyidagicha bo‘ladi:
3.30- rasm. Dasturning umumiy ko‘rinish oynasi
Dasturni tuzish quyidagi qadamlardan tashkil topgan:
qadam. Formaga webBrowser komponеntasini tashlang va
Form1 ning load hodisasining kodlari quyidagicha:
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
String^s="Oilam haqi ma`lumot
border=\"1\"> ";
s+=" Nomeri "; s+=" Qar_turi ";
6. s+=" Fam "; s+=" Ismi ";
s+=" Tel nomeri ";
char qar_turi[20]=""; char Ismi[20]="";
9. char Fam[20]=""; char Tel[20]="";
10. String^ss=""; FILE *oqi; int i=1,n; bool dd;
11. oqi=fopen("C:\\1.txt","r");
if(oqi==NULL){MessageBox::Show("Not found");}
while(!feof(oqi)){
fgets(qar_turi,20,oqi); fgets(Fam,20,oqi);
fgets(Ismi,20,oqi); dd=fgets(Tel,20,oqi);
if(dd==0){break;}
String^ Fq=gcnew String(qar_turi);
String^ Fi=gcnew String(Ismi);
String^ Fm=gcnew String(Fam);
String^ Ft=gcnew String(Tel);
21. s+=""+i.ToString()+" "; s+=" "+Fq+" ";
22. s+=" "+Fm+" "; s+=" "+Fi+" ";
23. s+=" "+Ft+" "; i++;} s+="
";
24. webBrowser1->Navigate("about:" + s); }
qadam. Formada saytlarni qidirish uchun Button va TextBox komponеntalari joylashtiriladi va Button1 tugmasining click hodisasining kodlari quyidagicha:
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) { if (!this->textBox1->Text->Equals("") ){
this->webBrowser1->Navigate( this->textBox1->Text );} }
qadam. Manzillar oynasiga vеb sayt manzili yoziladigan
TextBox1 hodisasi quyidagicha bo‘ladi:
private:System::Void textBox1_KeyDown(System::Object^ sender,
System::Windows:: Forms::KeyEventArgs^ e) {
if ( e->KeyCode == System::Windows::Forms::Keys::Enter &&
!this->textBox1->Text->Equals( "" ) ){ this->webBrowser1-
Do'stlaringiz bilan baham: