You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Pages: 1
我用了以下代码:但是不成功。
worksheet.CellEditCharInputed += (s,e) =>
{
if(e.InputChar >= 'a' && e.InputChar <= 'z')
{
e.InputChar = Char.ToUpper(Convert.ToChar(e.InputChar));
}
};
以上代码在winform中可以,请问是wpf的bug吗?
使用的是1.2.0
Last edited by adams_mfsor (2016-03-28 07:39:05)
Offline
I just did this in the WPF version 1.2.2
The problem you had was you didn't convert the char to integer value that the e.inputchar uses, since use ASCII numbers.
What you have to do is convert the Char to ASCII number then check it with the e.inputchar.
Try this code.. I just got to work and i change your convert toupper
worksheet.CellEditCharInputed += (s,e) =>
{
if(e.InputChar >= AscW('a') && e.InputChar <= AscW('z'))
{
e.InputChar = AscW(Convert.ToChar(e.InputChar).ToString.ToUpper);
}
};
you could do like this too
worksheet.CellEditCharInputed += (s,e) =>
{
if(e.InputChar >= 97 && e.InputChar <= 122)
{
e.InputChar = AscW(Convert.ToChar(e.InputChar).ToString.ToUpper);
}
};
Shane
Last edited by asparatu (2016-03-28 14:46:10)
Offline
hi, Shane
thanks for your help.
I do the same, but it still not work.
worksheet.CellEditCharInputed += (s, e) =>
{
if (e.InputChar >= AscW('a') && e.InputChar <= AscW('z'))
{
e.InputChar = AscW(Char.ToUpper(Convert.ToChar(e.InputChar)));
}
};
and the AscW function:
private int AscW(char p)
{
return (int)p;
}
I also try the next code. still not work.
worksheet.CellEditCharInputed += (s, e) =>
{
if (e.InputChar >= AscW('a') && e.InputChar <= AscW('z'))
{
e.InputChar = 65;
}
};
Last edited by adams_mfsor (2016-03-29 01:00:06)
Offline
Thanks Shane! This works in Windows Form edition but doesn't work in WPF. We'll try to fix the WPF edition from next release.
Last edited by Jingwood (2016-03-29 01:32:56)
Offline
Hello Jing and adams_mfsor,
If use this code, in Wpf it works, but only works if you press F2 or double click with the mouse, if you type with your keyboard the cellinputedchar event does not fire. this the also the same as my other code. Sorry i was trying convert from VB.net solution, but i did it in C# this time both times i used WPF.
I did use the same code in winforms and it work fine, when you type the cellinputedchar event fires..
So, adams_mfsor, you can use this in WPF but have press F2 or double click to put the sheet into edit mode or maybe, you can use BeforeCellKeyDown event that puts the cell in edit mode then end the edit when the cellinputedchar event done firing.
Tried to do it but keep giving null reference when use BeforeCellKeyDown and AfterCellKeyDown Event.
Shane
//omitted system genterated imports
using unvell.Common;
using unvell.ReoGrid;
using unvell.ReoGrid.Actions;
using unvell.ReoGrid.Events;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private Worksheet sheet;
public MainWindow()
{
InitializeComponent();
sheet = grid.CurrentWorksheet;
sheet.CellEditCharInputed += sheet_CellEditCharInputed;
}
private void sheet_CellEditCharInputed(object sender, CellEditCharInputEventArgs e)
{
if (e.InputChar >= 97 && e.InputChar <= 122)
{
e.InputChar = (int)Char.ToUpper(Convert.ToChar(e.InputChar));
}
}
}
}
Last edited by asparatu (2016-03-29 02:10:56)
Offline
Pages: 1