我想做一個在下拉框中能夠取得想word一樣的字體,程序如下,可是有錯誤提眎,不知道該怎嗎解決??

wscqstu 2002-11-08 09:16:41
源程序如下:
/// <summary>
/// 用於保存主窗?支持的字體族的名稱
/// </summary>
public string fontFamilyNames;

/// <summary>
/// 獲取主窗?支持的所有字體族
/// </summary>
private void GetFontFamilies()
{
Graphics g=this.CreateGraphics();
FontFamily[] ffs=FontFamily.GetFamilies(g);
fontFamilyNames=new string[ffs.Length];
~1~~
for(int i=0;i<ffs.Length;i++)
{
fontFamilyNames[i]=ffs[i].Name;
~~~~~~~~2~~~~~~~~ ~~~~3~~~~~
cbxFont.Items.Add(ffs[i].Name);
}
}

錯誤提眎如下:
1. Cannot implicitly convert type 'string[]' to 'string'

2.Property or indexer 'string.this[int]' cannot be assigned to -- it is read only

3. Cannot implicitly convert type 'string' to 'char'

...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wscqstu 2002-11-08
  • 打赏
  • 举报
回复
ok啦,給分
lhxiangbird 2002-11-08
  • 打赏
  • 举报
回复
public string fontFamilyNames;

应该改为

public string[] fontFamilyNames;

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧