OT Datagrid v Tabpage - VB VS2013
Ladislav Vaiz
spam na nagano.cz
Úterý Srpen 12 11:49:42 CEST 2014
Pavel Urbancik napsal(a):
Je to System.Windows.Forms a mam pouzity DataGridView
Udelal jsem v podstate jen form, vlozil tab co ma 4 zalozky.
Do 2. Zalozky vlozil datagridview a textbox.
Vse nechal v default a jen okopiroval kod z helpu na naplneni
Kod je pod textem.
Kdyz je datagridview na prvni zalozce, nebo primo ve formu, tak to chodi,
tzn program vlozi radky a vidim je.
Kdyz je datagrid na druhe zalozce, tak vidim jen jeden radek a klikanim se
ukazuje jen vybrany.
Zkusil jsem to v C# a funguje mi to dobře:
Kód:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace X
{
public partial class TestForm : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components =ull;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name=isposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components !=ull))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle
dataGridViewCellStyle1 =ew System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 =ew System.Windows.Forms.TabControl();
this.tabPage1 =ew System.Windows.Forms.TabPage();
this.tabPage2 =ew System.Windows.Forms.TabPage();
this.dataGridView1 =ew System.Windows.Forms.DataGridView();
this.Column1 =ew
System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 =ew
System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 =ew
System.Windows.Forms.DataGridViewTextBoxColumn();
this.tabPage3 =ew System.Windows.Forms.TabPage();
this.tabPage4 =ew System.Windows.Forms.TabPage();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Location =ew System.Drawing.Point(33, 33);
this.tabControl1.Name =tabControl1";
this.tabControl1.SelectedIndex =;
this.tabControl1.Size =ew System.Drawing.Size(629, 371);
this.tabControl1.TabIndex =;
//
// tabPage1
//
this.tabPage1.Location =ew System.Drawing.Point(4, 22);
this.tabPage1.Name =tabPage1";
this.tabPage1.Padding =ew System.Windows.Forms.Padding(3);
this.tabPage1.Size =ew System.Drawing.Size(621, 345);
this.tabPage1.TabIndex =;
this.tabPage1.Text =tabPage1";
this.tabPage1.UseVisualStyleBackColor =rue;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.dataGridView1);
this.tabPage2.Location =ew System.Drawing.Point(4, 22);
this.tabPage2.Name =tabPage2";
this.tabPage2.Padding =ew System.Windows.Forms.Padding(3);
this.tabPage2.Size =ew System.Drawing.Size(621, 345);
this.tabPage2.TabIndex =;
this.tabPage2.Text =tabPage2";
this.tabPage2.UseVisualStyleBackColor =rue;
//
// dataGridView1
//
this.dataGridView1.AutoSizeRowsMode
System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
this.dataGridView1.ColumnHeadersBorderStyle
System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle1.Alignment
System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor System.Drawing.Color.Navy;
dataGridViewCellStyle1.Font =ew
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(238)));
dataGridViewCellStyle1.ForeColor System.Drawing.Color.White;
dataGridViewCellStyle1.SelectionBackColor
System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor
System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode
System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView1.ColumnHeadersDefaultCellStyle
dataGridViewCellStyle1;
this.dataGridView1.ColumnHeadersHeightSizeMode
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new
System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2,
this.Column3});
this.dataGridView1.GridColor =ystem.Drawing.Color.Black;
this.dataGridView1.Location =ew System.Drawing.Point(67, 43);
this.dataGridView1.Name =dataGridView1";
this.dataGridView1.RowHeadersVisible =alse;
this.dataGridView1.Size =ew System.Drawing.Size(448, 198);
this.dataGridView1.TabIndex =;
//
// Column1
//
this.Column1.HeaderText =Column1";
this.Column1.Name =Column1";
//
// Column2
//
this.Column2.HeaderText =Column2";
this.Column2.Name =Column2";
//
// Column3
//
this.Column3.HeaderText =Column3";
this.Column3.Name =Column3";
//
// tabPage3
//
this.tabPage3.Location =ew System.Drawing.Point(4, 22);
this.tabPage3.Name =tabPage3";
this.tabPage3.Padding =ew System.Windows.Forms.Padding(3);
this.tabPage3.Size =ew System.Drawing.Size(621, 345);
this.tabPage3.TabIndex =;
this.tabPage3.Text =tabPage3";
this.tabPage3.UseVisualStyleBackColor =rue;
//
// tabPage4
//
this.tabPage4.Location =ew System.Drawing.Point(4, 22);
this.tabPage4.Name =tabPage4";
this.tabPage4.Padding =ew System.Windows.Forms.Padding(3);
this.tabPage4.Size =ew System.Drawing.Size(621, 345);
this.tabPage4.TabIndex =;
this.tabPage4.Text =tabPage4";
this.tabPage4.UseVisualStyleBackColor =rue;
//
// TestForm
//
this.AutoScaleDimensions =ew System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize =ew System.Drawing.Size(698, 452);
this.Controls.Add(this.tabControl1);
this.Name =TestForm";
this.Text =TestForm";
this.tabControl1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.TabPage tabPage4;
public TestForm()
{
InitializeComponent();
dataGridView1.Rows.Add(new string[] { "1", "2", "3" });
dataGridView1.Rows.Add(new string[] { "4", "5", "6" });
dataGridView1.Rows.Add(new string[] { "7", "8", "9" });
}
}
}
L.
Další informace o konferenci Hw-list