Click here to Skip to main content
15,893,161 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to extract part of HTML source? Pin
DerekT-P5-Nov-20 0:26
professionalDerekT-P5-Nov-20 0:26 
GeneralRe: How to extract part of HTML source? Pin
Member 5697395-Nov-20 3:56
Member 5697395-Nov-20 3:56 
QuestionHow to switch the whole DataGridView Left-To-right? Pin
Alex Dunlop4-Nov-20 7:46
Alex Dunlop4-Nov-20 7:46 
AnswerRe: How to switch the whole DataGridView Left-To-right? Pin
BillWoodruff4-Nov-20 14:21
professionalBillWoodruff4-Nov-20 14:21 
AnswerRe: How to switch the whole DataGridView Left-To-right? Pin
Mycroft Holmes5-Nov-20 10:50
professionalMycroft Holmes5-Nov-20 10:50 
QuestionMoving VS 2019 solution from on-premise to cloud Pin
Member 144746074-Nov-20 7:27
Member 144746074-Nov-20 7:27 
AnswerRe: Moving VS 2019 solution from on-premise to cloud Pin
Richard Andrew x644-Nov-20 14:05
professionalRichard Andrew x644-Nov-20 14:05 
QuestionWinForm - Localize DataGridView with automatical generated columns Pin
Mc_Topaz3-Nov-20 23:08
Mc_Topaz3-Nov-20 23:08 
Hi!

I have a DataGridView in a Windows Form application where I want to localize the columns in the DataGridView. I use the DataGridView 's DataSource property to populate the DataGridView from a list. Therefore the columns in the DataGridView are genereated automatically after the properies in the list.

Here is the code to populate the DataGridView.
C#
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        var p1 = new Person() { Name = "Foo", Age = 1337 };
        var p2 = new Person() { Name = "Bar", Age = 42 };
        var people = new List<Person>() { p1, p2 };
        dataGridView1.DataSource = people;
    }
}

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}
The generated columns in the DataGridView are Name and Age, the same as the properties in the Person class.


I have set the Form's Localizable property to True.
With a Label in the Form, I have verified that I can change the Label's Text property to different values based on the CurrentCulture / CurrentUICulture I set. I switch between different cultures in the Program.cs file:
C#
static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        var eng = "en";
        var swe = "sv-SE";
        var culture = eng;
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture);

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
My project have generated Form1.resx and Form1.sv.resx files to handle both English and Swedish. In these files I can find the label's text for the English and Swedish languages accordingly.

I just don't know how to set the DataGridView's column to different languages. Since the columns are not manually created by me I don't have the appropriate values in the Form1.resx and Form1.sv.resx to set the columns based on the selected language.

Is there any solution to this?
AnswerRe: WinForm - Localize DataGridView with automatical generated columns Pin
BillWoodruff4-Nov-20 2:35
professionalBillWoodruff4-Nov-20 2:35 
QuestionCsharp InTheHand.Net read bluetooth data on received event Pin
nowis773-Nov-20 8:07
nowis773-Nov-20 8:07 
AnswerRe: Csharp InTheHand.Net read bluetooth data on received event Pin
jsc423-Nov-20 10:33
professionaljsc423-Nov-20 10:33 
GeneralRe: Csharp InTheHand.Net read bluetooth data on received event Pin
nowis7710-Nov-20 21:01
nowis7710-Nov-20 21:01 
QuestionBusiness Layer Question Pin
Kevin Marois2-Nov-20 6:31
professionalKevin Marois2-Nov-20 6:31 
AnswerRe: Business Layer Question Pin
Richard Deeming2-Nov-20 6:45
mveRichard Deeming2-Nov-20 6:45 
GeneralRe: Business Layer Question Pin
Kevin Marois2-Nov-20 7:27
professionalKevin Marois2-Nov-20 7:27 
Questionuse connection from login form in other forms Pin
Newkid on the block31-Oct-20 5:43
Newkid on the block31-Oct-20 5:43 
AnswerRe: use connection from login form in other forms Pin
OriginalGriff31-Oct-20 5:57
mveOriginalGriff31-Oct-20 5:57 
GeneralRe: use connection from login form in other forms Pin
Newkid on the block31-Oct-20 10:21
Newkid on the block31-Oct-20 10:21 
GeneralRe: use connection from login form in other forms Pin
Dave Kreskowiak31-Oct-20 11:26
mveDave Kreskowiak31-Oct-20 11:26 
AnswerRe: use connection from login form in other forms Pin
Dave Kreskowiak31-Oct-20 6:30
mveDave Kreskowiak31-Oct-20 6:30 
AnswerRe: use connection from login form in other forms Pin
BillWoodruff1-Nov-20 15:12
professionalBillWoodruff1-Nov-20 15:12 
GeneralRe: use connection from login form in other forms Pin
Newkid on the block3-Nov-20 5:45
Newkid on the block3-Nov-20 5:45 
GeneralRe: use connection from login form in other forms Pin
BillWoodruff3-Nov-20 14:46
professionalBillWoodruff3-Nov-20 14:46 
QuestionCrystal reports and datagridviews Pin
Damir Djordjevic31-Oct-20 4:39
Damir Djordjevic31-Oct-20 4:39 
AnswerRe: Crystal reports and datagridviews Pin
Gerry Schmitz31-Oct-20 5:15
mveGerry Schmitz31-Oct-20 5:15 

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.