Click here to Skip to main content
15,890,123 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Dave Kreskowiak22-Jun-10 5:59
mveDave Kreskowiak22-Jun-10 5:59 
AnswerRe: How do I get a datagrid to only show certain columns from a dataset? Pin
meeram39522-Jun-10 1:17
meeram39522-Jun-10 1:17 
GeneralRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Terence van Schalkwyk22-Jun-10 1:21
Terence van Schalkwyk22-Jun-10 1:21 
AnswerRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Abhinav S22-Jun-10 1:19
Abhinav S22-Jun-10 1:19 
GeneralRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Terence van Schalkwyk22-Jun-10 1:25
Terence van Schalkwyk22-Jun-10 1:25 
AnswerRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Terence van Schalkwyk22-Jun-10 1:28
Terence van Schalkwyk22-Jun-10 1:28 
GeneralRe: How do I get a datagrid to only show certain columns from a dataset? Pin
darkelv22-Jun-10 1:42
darkelv22-Jun-10 1:42 
AnswerRe: How do I get a datagrid to only show certain columns from a dataset? Pin
darkelv22-Jun-10 1:33
darkelv22-Jun-10 1:33 
Define only the columns that you want to display in the datagridview:

this.dataGridView.AutoGenerateColumns = false;
this.dataGridView.Columns.Clear();
this.dataGridView.Columns.AddRange(GetGridViewColumns());


private DataGridViewColumn[] GetGridViewColumns()
{
DataGridViewTextBoxColumn id = new DataGridViewTextBoxColumn();
id .DataPropertyName = "ID";
id .HeaderText = "ID";
id .Name = "ID";
id .SortMode = DataGridViewColumnSortMode.Automatic;
id .ReadOnly = true;
id .Width = 100;
id .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
id .DefaultCellStyle.Format = "";

DataGridViewTextBoxColumn name= new DataGridViewTextBoxColumn();
name.DataPropertyName = "Name";
name.HeaderText = "Name";
name.Name = "Name";
name.SortMode = DataGridViewColumnSortMode.Automatic;
name.ReadOnly = true;
name.Width = 100;
name.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
name.DefaultCellStyle.Format = "";

return new DataGridViewColumn[] { id, name };
}

GeneralRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Terence van Schalkwyk22-Jun-10 1:42
Terence van Schalkwyk22-Jun-10 1:42 
AnswerRe: How do I get a datagrid to only show certain columns from a dataset? Pin
Bigdeak22-Jun-10 1:47
Bigdeak22-Jun-10 1:47 
QuestionXmlDocument.Save() throws expection when file name is containing colon ":". Pin
Piyush Vaishnav21-Jun-10 23:33
Piyush Vaishnav21-Jun-10 23:33 
AnswerRe: XmlDocument.Save() throws expection when file name is containing colon ":". Pin
Pete O'Hanlon21-Jun-10 23:42
mvePete O'Hanlon21-Jun-10 23:42 
AnswerRe: XmlDocument.Save() throws expection when file name is containing colon ":". Pin
freakyit22-Jun-10 0:40
freakyit22-Jun-10 0:40 
QuestionModfying Print Document Pin
Emmet_Brown21-Jun-10 23:13
Emmet_Brown21-Jun-10 23:13 
AnswerMessage Closed Pin
21-Jun-10 23:27
stancrm21-Jun-10 23:27 
GeneralRe: Modfying Print Document Pin
Emmet_Brown22-Jun-10 0:03
Emmet_Brown22-Jun-10 0:03 
AnswerRe: Modfying Print Document Pin
Emmet_Brown22-Jun-10 1:12
Emmet_Brown22-Jun-10 1:12 
QuestionRun a script on a linux box from Windows OS using windows-form written in C# Pin
ksaw12321-Jun-10 20:57
ksaw12321-Jun-10 20:57 
AnswerRe: Run a script on a linux box from Windows OS using windows-form written in C# Pin
Łukasz Nowakowski21-Jun-10 21:29
Łukasz Nowakowski21-Jun-10 21:29 
AnswerRe: Run a script on a linux box from Windows OS using windows-form written in C# Pin
Bernhard Hiller22-Jun-10 2:27
Bernhard Hiller22-Jun-10 2:27 
GeneralRe: Run a script on a linux box from Windows OS using windows-form written in C# Pin
Dave Kreskowiak22-Jun-10 3:54
mveDave Kreskowiak22-Jun-10 3:54 
QuestionExcel Exception from HRESULT: 0x800AC472 Pin
KaurGurpreet21-Jun-10 20:45
KaurGurpreet21-Jun-10 20:45 
AnswerMessage Closed Pin
21-Jun-10 22:29
stancrm21-Jun-10 22:29 
GeneralRe: Excel Exception from HRESULT: 0x800AC472 Pin
KaurGurpreet24-Jun-10 20:02
KaurGurpreet24-Jun-10 20:02 
Questionhow do i turn my usb into an U3 smart drive Pin
edward remo21-Jun-10 18:38
edward remo21-Jun-10 18:38 

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.