如何在 winform c# 中的 rdlc 报表查看器中显示印地语字符
How to display Hindi Characters in rdlc report viewer in winform c#
请提供此问题的解决方案。
我用印地语在 sql 中保存了记录,但是当我在 rdlc 报告查看器中显示时,它显示为一个框。
- SQL 数据库 - 我用印地语保存了记录。
服务代码
public class PaperRptModel
{
public string Subject { get; set; }
public string Course { get; set; }
public string Time { get; set; }
public int MaxMarks { get; set; }
public int PassMarks { get; set; }
readonly PaperGenEntities paperGenEntities = new PaperGenEntities();
public IList GetSingle(int Id)
{
List<PaperRptModel> paperRpts = new List<PaperRptModel>();
PaperRptModel model = new PaperRptModel();
var paper = paperGenEntities.Papers.FirstOrDefault(o => o.Id == Id);
var subject = paperGenEntities.Subjects.FirstOrDefault(o => o.Id == paper.Subject);
model.Course = $"{subject.EnglishCourse} ({subject.HindiCourse})";
model.Subject = $"{subject.EnglishName} ({subject.HindiName})"; ;
model.Time = paper.MaxTime;
model.MaxMarks = paper.TotalMarks ?? 0;
model.PassMarks = paper.PassMarks ?? 0;
paperRpts.Add(model);
return paperRpts;
}
public IList GetQuestions(int Id)
{
List<Question> questions = new List<Question>();
Question model = new Question();
var question = paperGenEntities.Questions.FirstOrDefault(o => o.Subject == Id);
model.EnglishName = question.EnglishName;
model.HindiName = question.HindiName;
model.DisplayMarks = question.DisplayMarks;
questions.Add(model);
return questions;
}
Window 表单代码
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
this.reportViewer1.LocalReport.DataSources.Clear();
var rptModel = new PaperRptModel();
var Model = rptModel.GetSingle(1);
var rds1 = new ReportDataSource("DataSet1", Model);
this.reportViewer1.LocalReport.DataSources.Add(rds1);
var question = new Question();
var questions = rptModel.GetQuestions(1);
var rds2 = new ReportDataSource("DataSet2", questions);
this.reportViewer1.LocalReport.DataSources.Add(rds2);
this.reportViewer1.RefreshReport();
}
}
结果为方框
如果您 运行 在 windows 客户端
检查您是否安装了印地语
(windows 10)
请提供此问题的解决方案。
我用印地语在 sql 中保存了记录,但是当我在 rdlc 报告查看器中显示时,它显示为一个框。
- SQL 数据库 - 我用印地语保存了记录。
服务代码
public class PaperRptModel { public string Subject { get; set; } public string Course { get; set; } public string Time { get; set; } public int MaxMarks { get; set; } public int PassMarks { get; set; } readonly PaperGenEntities paperGenEntities = new PaperGenEntities(); public IList GetSingle(int Id) { List<PaperRptModel> paperRpts = new List<PaperRptModel>(); PaperRptModel model = new PaperRptModel(); var paper = paperGenEntities.Papers.FirstOrDefault(o => o.Id == Id); var subject = paperGenEntities.Subjects.FirstOrDefault(o => o.Id == paper.Subject); model.Course = $"{subject.EnglishCourse} ({subject.HindiCourse})"; model.Subject = $"{subject.EnglishName} ({subject.HindiName})"; ; model.Time = paper.MaxTime; model.MaxMarks = paper.TotalMarks ?? 0; model.PassMarks = paper.PassMarks ?? 0; paperRpts.Add(model); return paperRpts; } public IList GetQuestions(int Id) { List<Question> questions = new List<Question>(); Question model = new Question(); var question = paperGenEntities.Questions.FirstOrDefault(o => o.Subject == Id); model.EnglishName = question.EnglishName; model.HindiName = question.HindiName; model.DisplayMarks = question.DisplayMarks; questions.Add(model); return questions; }
Window 表单代码
public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { this.reportViewer1.LocalReport.DataSources.Clear(); var rptModel = new PaperRptModel(); var Model = rptModel.GetSingle(1); var rds1 = new ReportDataSource("DataSet1", Model); this.reportViewer1.LocalReport.DataSources.Add(rds1); var question = new Question(); var questions = rptModel.GetQuestions(1); var rds2 = new ReportDataSource("DataSet2", questions); this.reportViewer1.LocalReport.DataSources.Add(rds2); this.reportViewer1.RefreshReport(); } }
结果为方框
如果您 运行 在 windows 客户端
检查您是否安装了印地语