Click here to Skip to main content
14,741,522 members
Home » Discussions » C#
   

C#

 
GeneralRe: How to extract part of HTML source? Pin
DerekT-P5-Nov-20 1:26
professionalDerekT-P5-Nov-20 1:26 
GeneralRe: How to extract part of HTML source? Pin
Member 5697395-Nov-20 4:56
MemberMember 5697395-Nov-20 4:56 
QuestionHow to switch the whole DataGridView Left-To-right? Pin
Alex Dunlop4-Nov-20 8:46
MemberAlex Dunlop4-Nov-20 8:46 
AnswerRe: How to switch the whole DataGridView Left-To-right? Pin
BillWoodruff4-Nov-20 15:21
mveBillWoodruff4-Nov-20 15:21 
AnswerRe: How to switch the whole DataGridView Left-To-right? Pin
Mycroft Holmes5-Nov-20 11:50
professionalMycroft Holmes5-Nov-20 11:50 
QuestionMoving VS 2019 solution from on-premise to cloud Pin
Member 144746074-Nov-20 8:27
MemberMember 144746074-Nov-20 8:27 
AnswerRe: Moving VS 2019 solution from on-premise to cloud Pin
Richard Andrew x644-Nov-20 15:05
professionalRichard Andrew x644-Nov-20 15:05 
QuestionWinForm - Localize DataGridView with automatical generated columns Pin
Mc_Topaz4-Nov-20 0:08
MemberMc_Topaz4-Nov-20 0: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.
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:
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 3:35
mveBillWoodruff4-Nov-20 3:35 
QuestionCsharp InTheHand.Net read bluetooth data on received event Pin
nowis773-Nov-20 9:07
Membernowis773-Nov-20 9:07 
AnswerRe: Csharp InTheHand.Net read bluetooth data on received event Pin
jsc423-Nov-20 11:33
professionaljsc423-Nov-20 11:33 
GeneralRe: Csharp InTheHand.Net read bluetooth data on received event Pin
nowis7710-Nov-20 22:01
Membernowis7710-Nov-20 22:01 
QuestionBusiness Layer Question Pin
Kevin Marois2-Nov-20 7:31
professionalKevin Marois2-Nov-20 7:31 
AnswerRe: Business Layer Question Pin
Richard Deeming2-Nov-20 7:45
mveRichard Deeming2-Nov-20 7:45 
GeneralRe: Business Layer Question Pin
Kevin Marois2-Nov-20 8:27
professionalKevin Marois2-Nov-20 8:27 
Questionuse connection from login form in other forms Pin
Newkid on the block31-Oct-20 6:43
MemberNewkid on the block31-Oct-20 6:43 
AnswerRe: use connection from login form in other forms Pin
OriginalGriff31-Oct-20 6:57
mveOriginalGriff31-Oct-20 6:57 
GeneralRe: use connection from login form in other forms Pin
Newkid on the block31-Oct-20 11:21
MemberNewkid on the block31-Oct-20 11:21 
GeneralRe: use connection from login form in other forms Pin
Dave Kreskowiak31-Oct-20 12:26
mveDave Kreskowiak31-Oct-20 12:26 
AnswerRe: use connection from login form in other forms Pin
Dave Kreskowiak31-Oct-20 7:30
mveDave Kreskowiak31-Oct-20 7:30 
AnswerRe: use connection from login form in other forms Pin
BillWoodruff1-Nov-20 16:12
mveBillWoodruff1-Nov-20 16:12 
GeneralRe: use connection from login form in other forms Pin
Newkid on the block3-Nov-20 6:45
MemberNewkid on the block3-Nov-20 6:45 
GeneralRe: use connection from login form in other forms Pin
BillWoodruff3-Nov-20 15:46
mveBillWoodruff3-Nov-20 15:46 
QuestionCrystal reports and datagridviews Pin
Damir Djordjevic31-Oct-20 5:39
MemberDamir Djordjevic31-Oct-20 5:39 
AnswerRe: Crystal reports and datagridviews Pin
Gerry Schmitz31-Oct-20 6:15
mveGerry Schmitz31-Oct-20 6: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.