Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.
Do more with
<span onclick="open('You clicked on +')">+</span><span onclick="open('You clicked on test')">This is test</span>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace DataGridViewCellContentClickDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Panel panel1;
private void InitializeComponent()
{
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.panel1 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(12, 12);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dataGridView1.Size = new System.Drawing.Size(563, 250);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(13, 295);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(182, 132);
this.panel1.TabIndex = 1;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(587, 439);
this.Controls.Add(this.panel1);
this.Controls.Add(this.dataGridView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn c = new DataColumn("Test Value");
dt.Columns.Add(c);
DataRow r = dt.NewRow();
r["Test Value"] = "+ This is test";
dt.Rows.Add(r);
dataGridView1.DataSource = dt;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int xOffSet = (int)(Screen.PrimaryScreen.Bounds.Width-(Screen.PrimaryScreen.Bounds.Width - Cursor.Position.X)-this.Left-dataGridView1.Left-30);
int xGridRatio = (int)(dataGridView1.Rows[0].Cells[0].ContentBounds.Width / 2);
if(xOffSet < xGridRatio)
{
MessageBox.Show("+");
}
else
{
MessageBox.Show("This is test");
}
}
}
}
Premium Content
You need an Expert Office subscription to comment.Start Free Trial