Click here to Skip to main content
15,867,568 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Attribute in .net Pin
Manikandan1011-Jun-14 3:46
professionalManikandan1011-Jun-14 3:46 
GeneralRe: Attribute in .net Pin
AmitGajjar29-May-14 6:44
professionalAmitGajjar29-May-14 6:44 
Questionhow to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75327-May-14 23:49
ven75327-May-14 23:49 
AnswerRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Eddy Vluggen28-May-14 0:28
professionalEddy Vluggen28-May-14 0:28 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75328-May-14 1:58
ven75328-May-14 1:58 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Eddy Vluggen28-May-14 3:00
professionalEddy Vluggen28-May-14 3:00 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75328-May-14 3:32
ven75328-May-14 3:32 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Eddy Vluggen28-May-14 5:06
professionalEddy Vluggen28-May-14 5:06 
Is this a WinForms datagrid (prolly not), an ASP.NET grid or a WPF-grid? In WinForms, life is simple;
C#
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        class Test
        {
            public string Item1 { get; set; }
            public string Item2 { get; set; }
            public string Item3 { get; set; }
        }

        DataGridView grid;
        public Form1()
        {
            List<Test> data = new List<Test>();
            data.Add(new Test() { Item1 = "bla", Item2 = "foos", Item3 = "bar" });

            InitializeComponent();
            grid = new DataGridView() { Dock = DockStyle.Fill };

            grid.DataSource = data;

            Controls.Add(grid);

            MessageBox.Show(string.Format("There are {0} columns in this grid", grid.Columns.Count));
        }

        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            grid.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
        }
    }
}

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75328-May-14 20:40
ven75328-May-14 20:40 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Pete O'Hanlon28-May-14 20:50
subeditorPete O'Hanlon28-May-14 20:50 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75329-May-14 0:11
ven75329-May-14 0:11 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Pete O'Hanlon29-May-14 0:15
subeditorPete O'Hanlon29-May-14 0:15 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75330-May-14 2:04
ven75330-May-14 2:04 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Pete O'Hanlon30-May-14 2:13
subeditorPete O'Hanlon30-May-14 2:13 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Dave Kreskowiak29-May-14 1:47
mveDave Kreskowiak29-May-14 1:47 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75330-May-14 2:05
ven75330-May-14 2:05 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Dave Kreskowiak30-May-14 4:12
mveDave Kreskowiak30-May-14 4:12 
AnswerRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Eddy Vluggen29-May-14 20:59
professionalEddy Vluggen29-May-14 20:59 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
ven75330-May-14 2:09
ven75330-May-14 2:09 
GeneralRe: how to change DataGrid specific column alignment to Center in C# programmatically Pin
Eddy Vluggen30-May-14 5:28
professionalEddy Vluggen30-May-14 5:28 
QuestionHelp with loop Pin
byka27-May-14 8:26
byka27-May-14 8:26 
AnswerRe: Help with loop Pin
Eddy Vluggen27-May-14 8:59
professionalEddy Vluggen27-May-14 8:59 
QuestionRetrieving the .NET 4.0 install path from a batch file Pin
Frank W. Wu23-May-14 5:55
Frank W. Wu23-May-14 5:55 
AnswerRe: Retrieving the .NET 4.0 install path from a batch file Pin
Richard MacCutchan23-May-14 6:11
mveRichard MacCutchan23-May-14 6:11 
GeneralRe: Retrieving the .NET 4.0 install path from a batch file Pin
Frank W. Wu23-May-14 6:19
Frank W. Wu23-May-14 6:19 

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.