Click here to Skip to main content
14,207,083 members
   

C#

 
GeneralRe: some bugs don't retire Pin
Dave Kreskowiak13-Jun-19 10:02
mveDave Kreskowiak13-Jun-19 10:02 
QuestionProcessId from ShDocVw.InternetExplorer(ShDocVw.ShellDocs) Pin
Member 1449598412-Jun-19 2:46
memberMember 1449598412-Jun-19 2:46 
AnswerRe: ProcessId from ShDocVw.InternetExplorer(ShDocVw.ShellDocs) Pin
OriginalGriff12-Jun-19 4:05
protectorOriginalGriff12-Jun-19 4:05 
GeneralRe: ProcessId from ShDocVw.InternetExplorer(ShDocVw.ShellDocs) Pin
BillWoodruff12-Jun-19 4:57
mveBillWoodruff12-Jun-19 4:57 
AnswerRe: ProcessId from ShDocVw.InternetExplorer(ShDocVw.ShellDocs) Pin
#realJSOP12-Jun-19 5:03
mve#realJSOP12-Jun-19 5:03 
AnswerRe: ProcessId from ShDocVw.InternetExplorer(ShDocVw.ShellDocs) Pin
Gerry Schmitz12-Jun-19 6:15
mveGerry Schmitz12-Jun-19 6:15 
GeneralRe: ProcessId from ShDocVw.InternetExplorer(ShDocVw.ShellDocs) Pin
Eddy Vluggen12-Jun-19 11:12
mveEddy Vluggen12-Jun-19 11:12 
QuestionDraw vertical bold lines between some columns in datagridview Pin
henryvuong10-Jun-19 15:48
memberhenryvuong10-Jun-19 15:48 
I want to draw vertical bold red lines between some columns in a datagridview. I created a form and a datagridview with six columns. I want to draw red bold vertical lines between first and second columns, and forth and fifth columns. Here's my code:

private void Form1_Load(object sender, EventArgs e)
 {
     //Add colums to dataGridView1
     this.dataGridView1.Columns.Add("Col_A", "Column A");
     this.dataGridView1.Columns.Add("Col_B", "Column B");
     this.dataGridView1.Columns.Add("Col_C", "Column C");
     this.dataGridView1.Columns.Add("Col_D", "Column D");
     this.dataGridView1.Columns.Add("Col_E", "Column E");
     this.dataGridView1.Columns.Add("Col_F", "Column F");

     //Add rows to datagridview
     for (int i = 0; i < 50; i++)
     {
         this.dataGridView1.Rows.Add("A" + i.ToString(), "B" + i.ToString(), "C" + i.ToString(),
                                     "D" + i.ToString(), "E" + i.ToString(), "F" + i.ToString());
     }

     //Set the width of columns
     for (int j = 0; j < this.dataGridView1.ColumnCount; j++)
     {
         this.dataGridView1.Columns[j].Width = 90;
     }

     this.dataGridView1.CellPainting += new DataGridViewCellPaintingEventHandler(dataGridView1_CellPainting);
 }

 //Cell painting event
 void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
 {
     //Using red pen to draw border
     using (var redPen = new Pen(Color.Red, 3))
     {
         //Get the x coordination value of the left line
         int left_x = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.Columns["Col_B"].Index, this.dataGridView1.Rows[0].Index, true).X;

         //Get the x coordination value of the right line
         int right_x = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.Columns["Col_D"].Index, this.dataGridView1.Rows[0].Index, true).X
                       + this.dataGridView1.GetCellDisplayRectangle(dataGridView1.Columns["Col_D"].Index,this.dataGridView1.Rows[0].Index, true).Width;

         //Get the y coordination value of the top of each line
         int top_y = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.Columns[0].Index, this.dataGridView1.Rows[0].Index, true).Y;

         //Get the y coordination value of the bottom of each line
         int bottom_y = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.Columns[0].Index, this.dataGridView1.Rows[dataGridView1.Rows.Count - 1].Index, true).Y
                        + this.dataGridView1.GetCellDisplayRectangle(dataGridView1.Columns[0].Index, this.dataGridView1.Rows[dataGridView1.Rows.Count - 1].Index, true).Height;

         //Draw the lines using red pen and the x, y values above
         e.Graphics.DrawLine(redPen, new Point(left_x, top_y), new Point(left_x, bottom_y));
         e.Graphics.DrawLine(redPen, new Point(right_x, top_y), new Point(right_x, bottom_y));
     }
 }


What I got is two vertical red lines in the header row, instead of the entire grid. If I reduce the number of rows to just a few so that all the rows will appear in the form what it first appears, then the red lines appear just as I wanted. But when some rows are hidden, it's screwed up. What am I missing?

Thanks.
AnswerRe: Draw vertical bold lines between some columns in datagridview Pin
OriginalGriff10-Jun-19 22:43
protectorOriginalGriff10-Jun-19 22:43 
GeneralRe: Draw vertical bold lines between some columns in datagridview Pin
henryvuong11-Jun-19 12:34
memberhenryvuong11-Jun-19 12:34 
GeneralRe: Draw vertical bold lines between some columns in datagridview Pin
OriginalGriff11-Jun-19 20:06
protectorOriginalGriff11-Jun-19 20:06 
SuggestionRe: Draw vertical bold lines between some columns in datagridview Pin
Richard MacCutchan10-Jun-19 22:43
protectorRichard MacCutchan10-Jun-19 22:43 
QuestionHow to create a tree node with menu, submenu, child, item Pin
Samiul078-Jun-19 17:05
memberSamiul078-Jun-19 17:05 
AnswerRe: How to create a tree node with menu, submenu, child, item Pin
Gerry Schmitz8-Jun-19 17:48
mveGerry Schmitz8-Jun-19 17:48 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
Samiul0710-Jun-19 0:21
memberSamiul0710-Jun-19 0:21 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
OriginalGriff10-Jun-19 1:23
protectorOriginalGriff10-Jun-19 1:23 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
Samiul0710-Jun-19 3:35
memberSamiul0710-Jun-19 3:35 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
OriginalGriff10-Jun-19 3:50
protectorOriginalGriff10-Jun-19 3:50 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
#realJSOP10-Jun-19 5:00
mve#realJSOP10-Jun-19 5:00 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
Gerry Schmitz10-Jun-19 5:47
mveGerry Schmitz10-Jun-19 5:47 
AnswerRe: How to create a tree node with menu, submenu, child, item Pin
BillWoodruff9-Jun-19 15:22
mveBillWoodruff9-Jun-19 15:22 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
Samiul0710-Jun-19 0:21
memberSamiul0710-Jun-19 0:21 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
BillWoodruff10-Jun-19 1:27
mveBillWoodruff10-Jun-19 1:27 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
Samiul0710-Jun-19 3:19
memberSamiul0710-Jun-19 3:19 
GeneralRe: How to create a tree node with menu, submenu, child, item Pin
OriginalGriff10-Jun-19 3:45
protectorOriginalGriff10-Jun-19 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190612.1 | Last Updated 15 Jun 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid